mirror of https://github.com/Shizmob/pydle.git
Allow non-generator factories to be decorated with @coroutine.
This is a no-op.
This commit is contained in:
parent
5491fa8a34
commit
ebc8f88c04
|
@ -5,6 +5,7 @@ import itertools
|
||||||
import collections
|
import collections
|
||||||
import threading
|
import threading
|
||||||
import datetime
|
import datetime
|
||||||
|
import types
|
||||||
|
|
||||||
import tornado.concurrent
|
import tornado.concurrent
|
||||||
import tornado.ioloop
|
import tornado.ioloop
|
||||||
|
@ -39,6 +40,11 @@ def coroutine(func):
|
||||||
|
|
||||||
# Handle initial value.
|
# Handle initial value.
|
||||||
gen = func(*args, **kwargs)
|
gen = func(*args, **kwargs)
|
||||||
|
|
||||||
|
# If this isn't a generator, then just return it.
|
||||||
|
if not isinstance(gen, types.GeneratorType):
|
||||||
|
return gen
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = next(gen)
|
result = next(gen)
|
||||||
if isinstance(result, tuple):
|
if isinstance(result, tuple):
|
||||||
|
|
Loading…
Reference in New Issue