[Twisted-Python] executing .rpy in a thread
ccom at gmx.net
Thu Sep 4 02:18:37 EDT 2003
Say I want to execute blocking code in a .rpy file. Can't I just execute
all the code in a separate thread? I've found the following code to
execute a function in a thread. How could I add a callback to that
thread so I could get back the whole html page back from that
"notthreadSafe" function and return it to the client (web browser)?
from twisted.internet import reactor
from twisted.python import threadable
"""do something that isn't thread-safe"""
"""Run in thread-safe manner."""
reactor.callFromThread(notThreadSafe, 3) # will run
# in the event loop
More information about the Twisted-Python