]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
wsgi: Document workaround for asyncio on multithreaded WSGI containers 2377/head
authorBen Darnell <ben@bendarnell.com>
Sat, 5 May 2018 18:26:52 +0000 (14:26 -0400)
committerBen Darnell <ben@bendarnell.com>
Sat, 5 May 2018 18:26:52 +0000 (14:26 -0400)
Fixes #2371

tornado/wsgi.py

index 892c0a929fa8544ae6bfe6c89724f2a060dc873f..beda0b9aa36317d2821edbace03fcbd0bdbd3d64 100644 (file)
@@ -181,6 +181,15 @@ class WSGIAdapter(object):
     that it is not possible to use `.AsyncHTTPClient`, or the
     `tornado.auth` or `tornado.websocket` modules.
 
+    In multithreaded WSGI servers on Python 3, it may be necessary to
+    permit `asyncio` to create event loops on any thread. Run the
+    following at startup (typically import time for WSGI
+    applications)::
+
+        import asyncio
+        from tornado.platform.asyncio import AnyThreadEventLoopPolicy
+        asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy())
+
     .. versionadded:: 4.0
 
     .. deprecated:: 5.1