Skip to content

Commit 6f98858

Browse files
authored
Replace asyncio.iscoroutinefunction with inspect.iscoroutinefunction
1 parent d43cf34 commit 6f98858

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/p4p/client/asyncio.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
_log = logging.getLogger(__name__)
44

55
import asyncio
6+
import inspect
67

78
from functools import partial, wraps
89

@@ -63,7 +64,7 @@ async def exec():
6364
await dostuff(ctxt, timeout=5)
6465
"""
6566
def decorate(fn):
66-
assert asyncio.iscoroutinefunction(fn), "Place @timesout before @coroutine"
67+
assert inspect.iscoroutinefunction(fn), "Place @timesout before @coroutine"
6768

6869
@wraps(fn)
6970
async def wrapper(*args, timeout=deftimeout, **kws):
@@ -291,7 +292,7 @@ def monitor(self, name, cb, request=None, notify_disconnect=False) -> "Subscript
291292
* A p4p.Value (Subject to :py:ref:`unwrap`)
292293
* A sub-class of Exception (Disconnected , RemoteError, or Cancelled)
293294
"""
294-
assert asyncio.iscoroutinefunction(cb), "monitor callback must be coroutine"
295+
assert inspect.iscoroutinefunction(cb), "monitor callback must be coroutine"
295296
R = Subscription(name, cb, notify_disconnect=notify_disconnect)
296297
cb = partial(get_running_loop().call_soon_threadsafe, R._E.set)
297298

src/p4p/test/asynciotest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from .utils import RefTestCase
1313

1414
import asyncio
15+
import inspect
1516

1617
from ..client.asyncio import Context, Disconnected, timesout
1718
from ..server.asyncio import SharedPV
@@ -31,7 +32,7 @@ class AsyncMeta(type):
3132
"""
3233
def __new__(klass, name, bases, classdict):
3334
for name, mem in classdict.items():
34-
if name.startswith('test') and asyncio.iscoroutinefunction(mem):
35+
if name.startswith('test') and inspect.iscoroutinefunction(mem):
3536
@wraps(mem)
3637
def wrapper(self, mem=mem):
3738
self.loop.run_until_complete(asyncio.wait_for(mem(self), self.timeout))

0 commit comments

Comments
 (0)