Re: request handling in a thread
Irmen de Jong <[email protected]>
| Newsgroups | gmane.comp.python.pyro |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 5-11-2012 4:04, Hilary Oliver wrote: > Hi, > > My application (Pyro3 as we still use connection authentication, as per my post to > this list a few months ago) currently looks like this (with hundreds of details > omitted): > > while True: process_many_pyro_connected_objects() # part 1 > pyro_daemon.handleRequests( timeout=1 ) # part 2 > > > The trouble is that when the number of pyro-connected objects gets large it takes > some time to process them (in part 1) and as a result responsiveness to user > requests goes down. Sorry if this is a stupid question - I'm new to threading - > but as far as Pyro is concerned is it ok to do continuous request handling in a > separate thread, like this: > > # thread 1 while True: process_many_pyro_connected_objects() > > # thread 2 while True: pyro_daemon.handleRequests() > > (so long as both threads only change the state of my pyro-connected objects in a > thread-safe way). It seems to work, and I assume it is ok, but thought maybe I > should check with the experts. Or is there a better way to do it? Sure, nothing wrong with this. Pyro proxies can also be used across threads, if need be. I do advise you to have a look at the 'allinone' and 'proxysharing' examples. Especially the 'allinone' example which does something similar to your setup (call pyro objects and have a server running at the same time in the same process). It has the event server thrown into the mix even. Also, have you considered making some remote method calls in your "part 1" that take up a long time to process, into oneway calls? Those may provide a large performance gain in certain situations (at the expense of not knowing the result of the call). Regards Irmen de Jong -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (Cygwin) Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBAgAGBQJQmEqOAAoJEHC9o7RHFlf2EZYIAOKPbsQ3FCBoR+2TbuFul3Uq Ey+36qRCexxaLEPjFL+sE22D2OJBk7T23EzJAQUq90tM/TVbzrHR85IwrZ5VSI7v royrF15wGDbBgUgwF1WhmfxnYSqZpikXetHtYaVSSAyigPMglur3Rk2MogFf8i8s ptHwIuewMsJvNUvi53bnyKgtZfn1nEO8XPqpVnsisBzQMZSXPDsJcbdnqNMFI8Zz ol4WbB1roIY08KEfhSK616X2LPrc5vCAhUbO/1vXAHDKMu1Pau20eKnDQvyaFMFT uaCOsY8EdJTRv0chCFIbRJ6pUUHiBciibHF8ZIbpaExPUXF8z04Qf8Yb57KZcnE= =36SA -----END PGP SIGNATURE----- ------------------------------------------------------------------------------ LogMeIn Central: Instant, anywhere, Remote PC access and management. Stay in control, update software, and manage PCs from one command center Diagnose problems and improve visibility into emerging IT issues Automate, monitor and manage. Do more in less time with Central http://p.sf.net/sfu/logmein12331_d2d