summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshipmints <shipmints@gmail.com>2019-10-15 22:16:14 -0400
committerAlex Grönholm <alex.gronholm@nextday.fi>2019-10-17 20:03:36 +0300
commitfe987a283d2bc96ea126861a220eb424182436b0 (patch)
treeb09bdb830003373866f1f9272604e3cc91a27055
parentd1df878c02defcd14c5a56d4c3a70011744fa219 (diff)
downloadapscheduler-fe987a283d2bc96ea126861a220eb424182436b0.tar.gz
Updated per suggestions from @agronholm.
-rw-r--r--apscheduler/executors/asyncio.py1
-rw-r--r--apscheduler/executors/tornado.py6
-rw-r--r--apscheduler/util.py8
-rw-r--r--tests/test_util.py20
4 files changed, 18 insertions, 17 deletions
diff --git a/apscheduler/executors/asyncio.py b/apscheduler/executors/asyncio.py
index 1bdeb78..2b8c619 100644
--- a/apscheduler/executors/asyncio.py
+++ b/apscheduler/executors/asyncio.py
@@ -2,7 +2,6 @@ from __future__ import absolute_import
import sys
-
from apscheduler.executors.base import BaseExecutor, run_job
from apscheduler.util import iscoroutinefunction_partial
diff --git a/apscheduler/executors/tornado.py b/apscheduler/executors/tornado.py
index 020d207..3b97eec 100644
--- a/apscheduler/executors/tornado.py
+++ b/apscheduler/executors/tornado.py
@@ -8,14 +8,12 @@ from tornado.gen import convert_yielded
from apscheduler.executors.base import BaseExecutor, run_job
try:
- from inspect import iscoroutinefunction
from apscheduler.executors.base_py3 import run_coroutine_job
+ from apscheduler.util import iscoroutinefunction_partial
except ImportError:
- def iscoroutinefunction(func):
+ def iscoroutinefunction_partial(func):
return False
-from apscheduler.util import iscoroutinefunction_partial
-
class TornadoExecutor(BaseExecutor):
"""
diff --git a/apscheduler/util.py b/apscheduler/util.py
index 5a3bce9..4b54309 100644
--- a/apscheduler/util.py
+++ b/apscheduler/util.py
@@ -5,7 +5,8 @@ from __future__ import division
from datetime import date, datetime, time, timedelta, tzinfo
from calendar import timegm
from functools import partial
-from inspect import isclass, ismethod, iscoroutinefunction
+from inspect import isclass, ismethod
+import asyncio
import re
from pytz import timezone, utc, FixedOffset
@@ -414,4 +415,7 @@ def check_callable_args(func, args, kwargs):
def iscoroutinefunction_partial(f):
while isinstance(f, partial):
f = f.func
- return iscoroutinefunction(f)
+
+ # The asyncio version of iscoroutinefunction includes testing for @coroutine
+ # decorations vs. the inspect version which does not.
+ return asyncio.iscoroutinefunction(f)
diff --git a/tests/test_util.py b/tests/test_util.py
index 441c60d..30ce06d 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -359,20 +359,20 @@ class TestCheckCallableArgs(object):
'kwargs: y')
-def not_a_coro(x):
- pass
-
-
-async def a_coro(x):
- pass
+class TestIsCoroutineFunctionPartial(object):
+ @staticmethod
+ def not_a_coro(x):
+ pass
+ @staticmethod
+ async def a_coro(x):
+ pass
-class TestIsCoroutineFunctionPartial(object):
def test_non_coro(self):
- assert iscoroutinefunction_partial(not_a_coro) is False
+ assert not iscoroutinefunction_partial(self.not_a_coro)
def test_coro(self):
- assert iscoroutinefunction_partial(a_coro) is True
+ assert iscoroutinefunction_partial(self.a_coro)
def test_coro_partial(self):
- assert iscoroutinefunction_partial(partial(a_coro, 1)) is True
+ assert iscoroutinefunction_partial(partial(self.a_coro, 1))