MCPcopy Index your code
hub / github.com/python-websockets/websockets / alarm

Function alarm

experiments/routing.py:27–39  ·  view source on GitHub ↗

Send the alarm time in the given timezone when it is reached.

(websocket, alarm_at, tzinfo)

Source from the content-addressed store, hash-verified

25
26
27async def alarm(websocket, alarm_at, tzinfo):
28 """Send the alarm time in the given timezone when it is reached."""
29 alarm_at = alarm_at.replace(tzinfo=tzinfo)
30 now = datetime.datetime.now(tz=datetime.timezone.utc)
31
32 try:
33 async with asyncio.timeout((alarm_at - now).total_seconds()):
34 await websocket.wait_closed()
35 except asyncio.TimeoutError:
36 try:
37 await websocket.send(alarm_at.isoformat())
38 except ConnectionClosed:
39 return
40
41
42async def timer(websocket, alarm_after):

Callers

nothing calls this directly

Calls 3

timeoutMethod · 0.80
wait_closedMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…