]> 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:44:04 +0000 (20:44 -0400)
tornado/platform/asyncio.py

index 162b36735d564ac829c04bb552f400ce12dff190..5d8f30738989a9e29ac5c0835fe7e30064698f49 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
 import os
@@ -18,6 +17,17 @@ import os
 from tornado.ioloop import IOLoop
 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):