[Twisted-Python] Asynchronous context in Twisted

Glyph Lefkowitz glyph at twistedmatrix.com
Sun Mar 27 22:03:59 EDT 2011


On Mar 15, 2011, at 2:54 AM, Fantix King wrote:

> Thanks for replying! :)

No problem, I wish I had time for more replies, but my stack runneth over.

> --- <asynchronous break point> ---

This is completely awesome, and I have had this message sitting around waiting for me to appropriately consider it and reply.  Hopefully I'll have some time in the future though.  Can you perhaps file a ticket in the Twisted tracker for "asynchronous tracebacks that show me what has happened to a Deferred" or something like that?  I think that we've all been afraid that such a feature would have too high of a performance cost, but like the creation/invocation stacks that are used when Deferred debugging is on, we could at least make use of it in unit tests or in debug mode.

Thanks again for this awesome demonstration, and I'm sorry I haven't had more time to look at it.

> Additionally, in my scenario of a 5 years old asynchronous Twisted web application, we
> need the "request" object available throughout all code between asynchronous network
> accesses and database accesses because our global configuration system needs the
> request object. It would greatly reduce our manual work to pass through the request
> object here and there to have a context working in the asynchronous way.

Okay, _this_ sounds terrible to me.  Implicitly requiring an out-of-band parameter that is retrieved via some global variable is a maintenance nightmare.  This is one of the reasons I haven't written and published more about trying to do more with asynchronous context: I don't want idiomatic Twisted applications to become a big mess of spaghetti code which only works if your call stacks are all just so.

Availability of an implicit/shared context object was one of the things that made maintaining old Woven and Nevow code such a pain, and I consider its complete elimination in twisted.web.template a major step forward.  So let's not go down that road again :).

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


More information about the Twisted-Python mailing list