[Twisted-Python] Crochet 1.5.0: Use Twisted in Django, Flask, or anywhere else

Glyph glyph at twistedmatrix.com
Wed Apr 13 20:57:23 MDT 2016


> On Apr 13, 2016, at 16:50, Itamar Turner-Trauring <itamar at itamarst.org> wrote:
> 
> On 04/13/2016 06:52 PM, Glyph wrote:
>> 
>> Do you think maybe it's time to integrate Crochet into Twisted proper, so we can obviate the need for the 'setup()' step, and just have the reactor do that itself?
>> 
> Well, setup() runs the reactor in a thread, which is probably not what you want in a regular Twisted program. For Twisted-native applications interacting with Crochet you don't want to do the auto-reactor mode, so you call no_setup() earlier in startup process, and then subsequent setup() calls (e.g. from other packages) are ignored.

One advantage of having this directly supported in Twisted, then, would be calling no_setup() (or equivalent) early on in 'twistd' and equivalent tools, so that crochet-using modules could be imported as part of a twisted-native plugin?

> So given it would have to have the same API as currently, I'm not sure what the benefit of integrating it into Twisted would be.

It might also be able to have a slightly different API.  For example, maybe setup() or some analogue thereof could set up an 'atexit' hook that runs the reactor if nobody gets around to calling run() before it exits?

-glyph



More information about the Twisted-Python mailing list