Skip to content

Commit b235699

Browse files
Address deprecations
1 parent 412a6cf commit b235699

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

src/socketio/async_admin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
from datetime import datetime, timezone
33
import functools
4+
import inspect
45
import os
56
import socket
67
import time
@@ -124,7 +125,7 @@ async def admin_connect(self, sid, environ, client_auth):
124125
elif isinstance(self.auth, list):
125126
authenticated = client_auth in self.auth
126127
else:
127-
if asyncio.iscoroutinefunction(self.auth):
128+
if inspect.iscoroutinefunction(self.auth):
128129
authenticated = await self.auth(client_auth)
129130
else:
130131
authenticated = self.auth(client_auth)

src/socketio/async_client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
import inspect
23
import logging
34
import random
45

@@ -375,7 +376,7 @@ async def _get_real_value(self, value):
375376
callables."""
376377
if not callable(value):
377378
return value
378-
if asyncio.iscoroutinefunction(value):
379+
if inspect.iscoroutinefunction(value):
379380
return await value()
380381
return value()
381382

@@ -437,7 +438,7 @@ async def _handle_ack(self, namespace, id, data):
437438
else:
438439
del self.callbacks[namespace][id]
439440
if callback is not None:
440-
if asyncio.iscoroutinefunction(callback):
441+
if inspect.iscoroutinefunction(callback):
441442
await callback(*data)
442443
else:
443444
callback(*data)
@@ -464,7 +465,7 @@ async def _trigger_event(self, event, namespace, *args):
464465
# first see if we have an explicit handler for the event
465466
handler, args = self._get_event_handler(event, namespace, args)
466467
if handler:
467-
if asyncio.iscoroutinefunction(handler):
468+
if inspect.iscoroutinefunction(handler):
468469
try:
469470
try:
470471
ret = await handler(*args)

src/socketio/async_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
import inspect
23

34
from engineio import packet as eio_packet
45
from socketio import packet
@@ -113,7 +114,7 @@ async def trigger_callback(self, sid, id, data):
113114
del self.callbacks[sid][id]
114115
if callback is not None:
115116
ret = callback(*data)
116-
if asyncio.iscoroutine(ret):
117+
if inspect.iscoroutine(ret):
117118
try:
118119
await ret
119120
except asyncio.CancelledError: # pragma: no cover

src/socketio/async_namespace.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
import inspect
23

34
from socketio import base_namespace
45

@@ -32,7 +33,7 @@ async def trigger_event(self, event, *args):
3233
handler_name = 'on_' + (event or '')
3334
if hasattr(self, handler_name):
3435
handler = getattr(self, handler_name)
35-
if asyncio.iscoroutinefunction(handler) is True:
36+
if inspect.iscoroutinefunction(handler) is True:
3637
try:
3738
try:
3839
ret = await handler(*args)
@@ -213,7 +214,7 @@ async def trigger_event(self, event, *args):
213214
handler_name = 'on_' + (event or '')
214215
if hasattr(self, handler_name):
215216
handler = getattr(self, handler_name)
216-
if asyncio.iscoroutinefunction(handler) is True:
217+
if inspect.iscoroutinefunction(handler) is True:
217218
try:
218219
try:
219220
ret = await handler(*args)

src/socketio/async_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
import inspect
23

34
import engineio
45

@@ -637,7 +638,7 @@ async def _trigger_event(self, event, namespace, *args):
637638
# first see if we have an explicit handler for the event
638639
handler, args = self._get_event_handler(event, namespace, args)
639640
if handler:
640-
if asyncio.iscoroutinefunction(handler):
641+
if inspect.iscoroutinefunction(handler):
641642
try:
642643
try:
643644
ret = await handler(*args)

0 commit comments

Comments
 (0)