Miguel Grinberg
5 months ago
Failed to extract signature
5 changed files with
13 additions and
8 deletions
-
src/socketio/async_admin.py
-
src/socketio/async_client.py
-
src/socketio/async_manager.py
-
src/socketio/async_namespace.py
-
src/socketio/async_server.py
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
import asyncio |
|
|
|
from datetime import datetime, timezone |
|
|
|
import functools |
|
|
|
import inspect |
|
|
|
import os |
|
|
|
import socket |
|
|
|
import time |
|
|
|
@ -124,7 +125,7 @@ class InstrumentedAsyncServer: |
|
|
|
elif isinstance(self.auth, list): |
|
|
|
authenticated = client_auth in self.auth |
|
|
|
else: |
|
|
|
if asyncio.iscoroutinefunction(self.auth): |
|
|
|
if inspect.iscoroutinefunction(self.auth): |
|
|
|
authenticated = await self.auth(client_auth) |
|
|
|
else: |
|
|
|
authenticated = self.auth(client_auth) |
|
|
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
import asyncio |
|
|
|
import inspect |
|
|
|
import logging |
|
|
|
import random |
|
|
|
|
|
|
|
@ -375,7 +376,7 @@ class AsyncClient(base_client.BaseClient): |
|
|
|
callables.""" |
|
|
|
if not callable(value): |
|
|
|
return value |
|
|
|
if asyncio.iscoroutinefunction(value): |
|
|
|
if inspect.iscoroutinefunction(value): |
|
|
|
return await value() |
|
|
|
return value() |
|
|
|
|
|
|
|
@ -437,7 +438,7 @@ class AsyncClient(base_client.BaseClient): |
|
|
|
else: |
|
|
|
del self.callbacks[namespace][id] |
|
|
|
if callback is not None: |
|
|
|
if asyncio.iscoroutinefunction(callback): |
|
|
|
if inspect.iscoroutinefunction(callback): |
|
|
|
await callback(*data) |
|
|
|
else: |
|
|
|
callback(*data) |
|
|
|
@ -464,7 +465,7 @@ class AsyncClient(base_client.BaseClient): |
|
|
|
# first see if we have an explicit handler for the event |
|
|
|
handler, args = self._get_event_handler(event, namespace, args) |
|
|
|
if handler: |
|
|
|
if asyncio.iscoroutinefunction(handler): |
|
|
|
if inspect.iscoroutinefunction(handler): |
|
|
|
try: |
|
|
|
try: |
|
|
|
ret = await handler(*args) |
|
|
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
import asyncio |
|
|
|
import inspect |
|
|
|
|
|
|
|
from engineio import packet as eio_packet |
|
|
|
from socketio import packet |
|
|
|
@ -113,7 +114,7 @@ class AsyncManager(BaseManager): |
|
|
|
del self.callbacks[sid][id] |
|
|
|
if callback is not None: |
|
|
|
ret = callback(*data) |
|
|
|
if asyncio.iscoroutine(ret): |
|
|
|
if inspect.iscoroutine(ret): |
|
|
|
try: |
|
|
|
await ret |
|
|
|
except asyncio.CancelledError: # pragma: no cover |
|
|
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
import asyncio |
|
|
|
import inspect |
|
|
|
|
|
|
|
from socketio import base_namespace |
|
|
|
|
|
|
|
@ -32,7 +33,7 @@ class AsyncNamespace(base_namespace.BaseServerNamespace): |
|
|
|
handler_name = 'on_' + (event or '') |
|
|
|
if hasattr(self, handler_name): |
|
|
|
handler = getattr(self, handler_name) |
|
|
|
if asyncio.iscoroutinefunction(handler) is True: |
|
|
|
if inspect.iscoroutinefunction(handler) is True: |
|
|
|
try: |
|
|
|
try: |
|
|
|
ret = await handler(*args) |
|
|
|
@ -213,7 +214,7 @@ class AsyncClientNamespace(base_namespace.BaseClientNamespace): |
|
|
|
handler_name = 'on_' + (event or '') |
|
|
|
if hasattr(self, handler_name): |
|
|
|
handler = getattr(self, handler_name) |
|
|
|
if asyncio.iscoroutinefunction(handler) is True: |
|
|
|
if inspect.iscoroutinefunction(handler) is True: |
|
|
|
try: |
|
|
|
try: |
|
|
|
ret = await handler(*args) |
|
|
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
import asyncio |
|
|
|
import inspect |
|
|
|
|
|
|
|
import engineio |
|
|
|
|
|
|
|
@ -637,7 +638,7 @@ class AsyncServer(base_server.BaseServer): |
|
|
|
# first see if we have an explicit handler for the event |
|
|
|
handler, args = self._get_event_handler(event, namespace, args) |
|
|
|
if handler: |
|
|
|
if asyncio.iscoroutinefunction(handler): |
|
|
|
if inspect.iscoroutinefunction(handler): |
|
|
|
try: |
|
|
|
try: |
|
|
|
ret = await handler(*args) |
|
|
|
|