IRC Chat with Itamar regarding using the Reactor in a threaded application
bkirsch OSAF is working on a Thread Personal Information Management System called Chandler
bkirsch so with in our threaded app
bkirsch we need to run a reactor in a separate thread
bkirsch and have our twisted code all use that reactor
bkirsch so a request from the main thread to retrieve mail kicks off a new thread which needs to get a reference to the reactor running in another thread potential
bkirsch connect to a tcp host via the reactor and retrieve mail
bkirsch then poat back to the main thread
itamar to run functions in reactor thread
itamar reactor.callFromThread(function, arg1, kw=1)
bkirsch mean while another aspect of Chandler may be using the reactor from another thread to get calendar info for examples
itamar that *schedules* it
itamar that's fine, as long as you use reactor.callFromThread
itamar instead of scheduling the function you want directly
bkirsch so it is possible for for multiple threads to use the reactor at the same time and perform separate actrions?
bkirsch correct?
itamar no
itamar it's possible for multiple threads to schedule stuff to run in reactor thread
itamar which gives same effect
itamar but you have to understand how it works to get it right
bkirsch that is fine
bkirsch are there any performance issues there
bkirsch can you set up multiple reactor instances?
bkirsch at the same time
Jerub the performance issue is something you're already experiencing - the GIL.
bkirsch interesting
bkirsch are there any examples of multi thread scheduling
bkirsch I can look at
bkirsch we are trying to figure out how best to incorporate Twisted and the Reactor thread configurayion is gonna be the key to getting it right
itamar you can't do multiple reactor instances
itamar and there's no need fo rit
itamar bkirsch: what you wwant is a wrapper around reactor.callFromThread
itamar bkirsch: which calls function in twisted thread
itamar but from caller's point of view blocks until you get a result
itamar or exception
itamar 10 lines of code or so
itamar and then a thread can just x = blockFromThread(f, 1) and f(1) will get called in reactor thread
itamar and caller thread will block until result is available, at which point blockFromThread will return it
|<-- ducky_linux has left irc.freenode.net ("hmmpf, somehow started mozilla as root")
bkirsch Itamar: will this work well when many different thread tasks are utilizing the Reactor?
itamar yep
--
BrianKirsch - 27 May 2004