File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -251,9 +251,9 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]:
251251 for route , ctx in self ._applications .items ():
252252 doc_handler = DocHandler (self , application_context = ctx )
253253 self .app .add_api_route (f"{ route } " , doc_handler .get , methods = ["GET" ])
254- ws_handler = WSHandler (self , application_context = ctx )
254+ ws_handler = WSHandler . create_factory (self , application_context = ctx )
255255 route = route if route .endswith ("/" ) else f"{ route } /"
256- self .app .add_websocket_route (f"{ route } ws" , ws_handler . ws_connect )
256+ self .app .add_websocket_route (f"{ route } ws" , ws_handler )
257257
258258 # Mount static file handlers
259259 for ext_name , ext_path in extension_dirs .items ():
Original file line number Diff line number Diff line change @@ -140,6 +140,13 @@ def __init__(
140140 self .connection = None
141141 self ._socket : WebSocket
142142
143+ @classmethod
144+ def create_factory (cls , application : BokehFastAPI , application_context : ApplicationContext ):
145+ def create_handler (* args , ** kwargs ):
146+ inst = cls (application , application_context )
147+ return inst .ws_connect (* args , ** kwargs )
148+ return create_handler
149+
143150 def check_origin (self , origin : str ) -> bool :
144151 """Implement a check_origin policy for Tornado to call.
145152
You can’t perform that action at this time.
0 commit comments