[Twisted-Python] Synchronous Code Fishbowl

Ed Suominen general at eepatents.com
Mon May 29 15:46:29 MDT 2006


Glyph wrote:
> syncbridge looks like an interesting module.  I've often wanted to do
> something similar, to have a "one right way" for integrating with
> non-async-clean legacy code which also doesn't necessarily support
> threaded concurrency either.
> 
> However, I notice that nothing sets up the 'shutdown' method to be
> called on reactor shutdown automatically; this is a very tricky area,
> since mismanaged thread-pool shutdown can lock a process up hard as
> it's exiting.
> 
> Also, have you considered just using a twisted.python.threadpool of
> maximum size 1, rather than callInThread?  The main reason I didn't
> document that as the aforementioned "one right way" was because of
> the associated shutdown issues.  The major advantage of callInThread
> is that the reactor's own threadpool is definitely initialized and
> shut down at predictable points.

Well of course, Glyph's "interesting module" comment was just enough of
a table scrap to get me running, tail wagging furiously. The result
(unit testing in progress) is a full-fledged SynchronousTasks object
that runs a priority queue of synchronous tasks with niceness
scheduling. See

* http://foss.eepatents.com/sAsync/browser/trunk/sasync/syncbridge.py
* http://foss.eepatents.com/sAsync/browser/trunk/test/syncbridge.py

Once fully tested, would SynchronousTasks be considered as an addition
to twisted.internet.threads?

Best regards, Ed




More information about the Twisted-Python mailing list