From 16a3567b68f23ae4386eaf881f6a8584968d33d9 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sat, 5 May 2018 14:26:52 -0400 Subject: [PATCH] wsgi: Document workaround for asyncio on multithreaded WSGI containers Fixes #2371 --- tornado/wsgi.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tornado/wsgi.py b/tornado/wsgi.py index 892c0a929..beda0b9aa 100644 --- a/tornado/wsgi.py +++ b/tornado/wsgi.py @@ -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 -- 2.47.2