From: Ben Darnell Date: Tue, 27 May 2014 00:41:52 +0000 (-0400) Subject: Fix imports for the new version of trollius, which changed its package name. X-Git-Tag: v3.2.2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f76f51a316a67f5877c78ec788066e58d8e40723;p=thirdparty%2Ftornado.git Fix imports for the new version of trollius, which changed its package name. --- diff --git a/tornado/platform/asyncio.py b/tornado/platform/asyncio.py index 162b36735..5d8f30738 100644 --- a/tornado/platform/asyncio.py +++ b/tornado/platform/asyncio.py @@ -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):