Allow non-generator factories to be decorated with @coroutine.

This is a no-op.
This commit is contained in:
Tony Young 2014-02-20 23:00:50 +13:00
parent 5491fa8a34
commit ebc8f88c04
1 changed files with 6 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import itertools
import collections
import threading
import datetime
import types
import tornado.concurrent
import tornado.ioloop
@ -39,6 +40,11 @@ def coroutine(func):
# Handle initial value.
gen = func(*args, **kwargs)
# If this isn't a generator, then just return it.
if not isinstance(gen, types.GeneratorType):
return gen
try:
result = next(gen)
if isinstance(result, tuple):