On Thu, 28 Apr 2005 12:34:33 +0000 (UTC), Operation Latte Thunder <[EMAIL PROTECTED]> wrote:
Jason Mobarak <[EMAIL PROTECTED]> wrote:
Why do you want to do this in a thread? What's wrong with
reactor.callLater?
import time
from twisted.internet import reactor
def shutdown():
time.sleep(3)
print "stopping"
reactor.callFromThread(reactor.stop)
reactor.callInThread(shutdown)
reactor.run()
In the app I am playing with, I have a thread that reads from the console.
When it terminates, I wanted it to shut down the reactor and couldn't use
callLater. However, callFromThread worked perfectly. I guess I need to
look at the docs some more to understand why its necessary
In general, you cannot call Twisted APIs from a thread other than that in
which the reactor is executing. There are a few exceptions, callFromThread
being one of them, but in general doing so has unpredictable behavior and is
not supported.
You also may be interested in twisted.internet.stdio and, in Twisted 2.0,
twisted.conch.insults.
Jp
--
http://mail.python.org/mailman/listinfo/python-list