MCPcopy
hub / github.com/nonebot/nonebot2 / background_task

Function background_task

tests/test_driver.py:183–192  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

181
182 # create a background task before the ws connection established
183 async def background_task():
184 try:
185 await ws_ready.wait()
186 assert ws is not None
187
188 await ws.send("ping")
189 data = await ws.receive()
190 assert data == "pong"
191 finally:
192 ws_should_close.set()
193
194 async def _handle_ws(websocket: WebSocket) -> None:
195 nonlocal ws

Callers

nothing calls this directly

Calls 4

waitMethod · 0.80
setMethod · 0.80
sendMethod · 0.45
receiveMethod · 0.45

Tested by

no test coverage detected