Using Twisted Words in a WSGI Container

I run django on a twisted wsgi container. Obviously, I avoid all asynchronous things with delays inside my django code, because, according to the documentation, twisted asynchronous access capabilities are not allowed in WSGI applications.

However, I would like to use twisted.words in my WSGI application to send requests to the jabber server. Is this considered as asynchronous material or can I use it in my application? What can happen if I send twisted.words jabber requests to the xmpp server inside WSGI?

Moreover, I have a more general question. Is there any reason why a twisted WSGI container is multithreaded (multithreaded?), Since it is well known by python. GIL reduces overall script performance with threads.

Thanks for any answers.

+5
source share
1 answer

To call a function in the main events loop (input / output stream) in Twisted from another thread (thread / poison thread, for example, WSGI application thread), you can use reactor.callFromThread(). If you want to wait for the results, use threads.blockingCallFromThread(). This way you can call functions that use twisted.wordsSee Using streams in Twisted .

, wsgi wsgi.multithread, true .

WSGI , ( , ). ( ) , . , , .

Python, , , , GIL . , -, webapps, , CPU.

0

All Articles