You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Long-running callbacks that use loops **must** check `ws.is_shutdown` to detect when the WebSocket connection has closed. Without this check:
1001
+
- Callbacks continue running after the client disconnects, wasting server resources
1002
+
-`set_props` calls go to a closed connection and are lost
1003
+
- The callback result is never delivered to the client
1004
+
1005
+
Only "persistent callbacks" (callbacks with no Output and no Input that use only `set_props`) are automatically restarted when the WebSocket reconnects. Regular callbacks with outputs are not restarted.
1006
+
994
1007
**API:**
995
1008
-`set_props(component_id, props_dict)`- Stream prop updates immediately to client
996
1009
-`ctx.websocket`- Get WebSocket interface (returns `None`ifnotinWS context)
1010
+
-`ws.is_shutdown`- Check if the WebSocket connection has been closed
997
1011
-`await ws.get_prop(component_id, prop_name)`- Read current prop value from client
998
1012
-`await ws.set_prop(component_id, prop_name, value)`- Set single prop (async version)
999
1013
-`await ws.close(code, reason)`- Close the WebSocket connection
0 commit comments