Skip to content

Commit

Permalink
Include our own version of isgenerator() for Python 2.5 and below.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Naeseth committed Feb 25, 2010
1 parent b800cee commit d1ac84d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions swirl.py
Expand Up @@ -4,12 +4,19 @@
Provides some sugar to make Tornado's async stuff more palatable.
"""

import inspect
import logging
import functools
from tornado.ioloop import IOLoop
from tornado.web import RequestHandler, asynchronous as web_async

try:
from inspect import isgenerator
except ImportError:
# Python < 2.6
import types
def isgenerator(obj):
return isinstance(obj, types.GeneratorType)

__version__ = '0.1.0'

def make_asynchronous_decorator(io_loop):
Expand Down Expand Up @@ -37,7 +44,7 @@ def run_async_routine(*args, **kwargs):
web_handler = None

gen = routine(*args, **kwargs)
if not inspect.isgenerator(gen):
if not isgenerator(gen):
# the "coroutine" isn't actually a coroutine; just return
# its result like tornado.web.asynchronous would do
return gen
Expand Down

0 comments on commit d1ac84d

Please sign in to comment.