From ebc8f88c04976231fa2dfe011e5de9676fe323d5 Mon Sep 17 00:00:00 2001 From: Tony Young Date: Thu, 20 Feb 2014 23:00:50 +1300 Subject: [PATCH] Allow non-generator factories to be decorated with @coroutine. This is a no-op. --- pydle/async.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pydle/async.py b/pydle/async.py index b73fead..3a07707 100644 --- a/pydle/async.py +++ b/pydle/async.py @@ -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):