]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Fix imports for the new version of trollius, which changed its package name.
authorBen Darnell <ben@bendarnell.com>
Tue, 27 May 2014 00:41:52 +0000 (20:41 -0400)
committerBen Darnell <ben@bendarnell.com>
Tue, 27 May 2014 00:41:52 +0000 (20:41 -0400)
tornado/platform/asyncio.py

index 3f86cc7d1c999fa5424ac832f6c899093276ce84..552476bc0800a8e0eed7f88caa782b980a8fec07 100644 (file)
@@ -10,7 +10,6 @@ unfinished callbacks on the event loop that fail when it resumes)
 """
 
 from __future__ import absolute_import, division, print_function, with_statement
-import asyncio
 import datetime
 import functools
 
@@ -18,6 +17,17 @@ import functools
 from tornado.ioloop import IOLoop, _Timeout
 from tornado import stack_context
 
+try:
+    # Import the real asyncio module for py33+ first.  Older versions of the
+    # trollius backport also use this name.
+    import asyncio
+except ImportError as e:
+    # Asyncio itself isn't available; see if trollius is (backport to py26+).
+    try:
+        import trollius as asyncio
+    except ImportError:
+        # Re-raise the original asyncio error, not the trollius one.
+        raise e
 
 class BaseAsyncIOLoop(IOLoop):
     def initialize(self, asyncio_loop, close_loop=False):