[Twisted-Python] Asynchronously initializing objects in twisted.web?

Nagy, Attila bra at fsn.hu
Tue Sep 8 08:51:04 MDT 2015


Hi,

I wonder, if I have this example program:
https://twistedmatrix.com/documents/current/web/howto/using-twistedweb.html#site-objects

how do I initialize an external resource (like a dictionary, which is 
fetched from a database) with asynchronous twisted tools, but before the 
HTTP server starts listening on its port?
The goal here is that the HTTP server shouldn't start until it can fetch 
the desired data. Of course I can do this in a synchronous way, but it 
feels so unnatural and bad practice to fetch the same stuff 
synchronously on initialization and asynchronously when the 
program/reactor is running (often with different libraries).

Thanks,



More information about the Twisted-Python mailing list