[Twisted-Python] Mimicking a blocking API using Twisted

Glyph glyph at twistedmatrix.com
Sun Mar 25 21:54:38 EDT 2012


On Mar 25, 2012, at 9:27 PM, Paul Reznicek wrote:

> I have similar needs and did not found usable answers, so I wrote some
> q&d hacks for doctests and also for UI interactions, where the user should
> be blocked until something in non-blocking deferred finish or "time-outed".

These hacks are all pretty awful, and you generally shouldn't use them.

For doctests, I don't know that you can do much better (although doing what I said, and structuring your code so that the doctests can explicitly fire in-memory Deferreds or make callbacks directly instead of spinning the reactor, would be a better idea).

(Bottom line: don't use doctests.)

For user interactions, if you want to pause the ability of a user to perform certain interactions, explicitly pause or disable those interactions.  Pretty much every GUI toolkit has a way to disable or grey out certain controls, and you should use those APIs rather than entering a broken re-entrant main loop with unsupported APIs.

-glyph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20120325/6537cb60/attachment.htm 


More information about the Twisted-Python mailing list