MCPcopy Create free account
hub / github.com/miguelgrinberg/python-socketio / wrapped

Function wrapped

tests/async/test_admin.py:23–69  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

21 def decorator(f):
22 @wraps(f)
23 def wrapped(self, *args, **kwargs):
24 sio = socketio.AsyncServer(async_mode='asgi')
25
26 @sio.event
27 async def enter_room(sid, data):
28 await sio.enter_room(sid, data)
29
30 @sio.event
31 async def emit(sid, event):
32 await sio.emit(event, skip_sid=sid)
33
34 @sio.event(namespace='/foo')
35 def connect(sid, environ, auth):
36 pass
37
38 async def shutdown():
39 await self.isvr.shutdown()
40 await sio.shutdown()
41
42 if 'server_stats_interval' not in ikwargs:
43 ikwargs['server_stats_interval'] = 0.25
44
45 self.isvr = sio.instrument(auth=auth, **ikwargs)
46 server = SocketIOWebServer(sio, on_shutdown=shutdown)
47 server.start()
48
49 # import logging
50 # logging.getLogger('engineio.client').setLevel(logging.DEBUG)
51 # logging.getLogger('socketio.client').setLevel(logging.DEBUG)
52
53 original_schedule_ping = EngineIOSocket.schedule_ping
54 EngineIOSocket.schedule_ping = mock.MagicMock()
55
56 try:
57 ret = f(self, *args, **kwargs)
58 finally:
59 server.stop()
60 self.isvr.uninstrument()
61 self.isvr = None
62
63 EngineIOSocket.schedule_ping = original_schedule_ping
64
65 # import logging
66 # logging.getLogger('engineio.client').setLevel(logging.NOTSET)
67 # logging.getLogger('socketio.client').setLevel(logging.NOTSET)
68
69 return ret
70 return wrapped
71 return decorator
72

Callers

nothing calls this directly

Calls 5

instrumentMethod · 0.95
startMethod · 0.95
stopMethod · 0.95
SocketIOWebServerClass · 0.90
uninstrumentMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…