L iUddlmZddlmZmZmZddlmZddlm Z ddl m Z m Z m Z mZmZerddlmZddlmZddlmZdd lmZeeZd ed <Gd d eZy)) annotations) TYPE_CHECKINGFinalcast) get_logger) AppSession)ActiveSessionInfo SessionClient SessionInfoSessionManagerSessionStorage)Callable) ScriptData) ScriptCache)UploadedFileManagerr_LOGGERceZdZdZ d dZ d ddZddZddZddZddZ dd Z dd Z dd Z y)WebsocketSessionManageraA SessionManager used to manage sessions with lifecycles tied to those of a browser tab's websocket connection. WebsocketSessionManagers differentiate between "active" and "inactive" sessions. Active sessions are those with a currently active websocket connection. Inactive sessions are sessions without. Eventual cleanup of inactive sessions is a detail left to the specific SessionStorage that a WebsocketSessionManager is instantiated with. cJ||_||_||_||_i|_yN)_session_storage_uploaded_file_mgr _script_cache_message_enqueued_callback_active_session_info_by_id)selfsession_storageuploaded_file_manager script_cachemessage_enqueued_callbacks q/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/runtime/websocket_session_manager.py__init__z WebsocketSessionManager.__init__1s0!0"7)*C'IK'NcN|r |r td||jvrtjd||xr+||jvxr|jj |}t |tr{|j}|jt|||j|j|j<|jj|j|jSt||j|j |j"||}tj%dt||j|j|jvrtd|jdt|||j|j<|jS)NzcOnly one of existing_session_id and session_id_override should be truthy. This should never happen.zESession with id %s is already connected! Connecting to a new session.) script_datarrr user_infosession_id_overridez1Created new session for client %s. Session ID: %sz session.id 'z6' registered multiple times. This should never happen.) RuntimeErrorrrwarningrget isinstancer sessionregister_file_watchersr script_run_countiddeleterrrrdebug) rclientr%r&existing_session_idr' session_infoexisting_sessionr,s r!connect_sessionz'WebsocketSessionManager.connect_session@s #6,  $"A"A A OOW#   ?#4+J+JJ ?%%))*=>  lK 0+33   3 3 5CT --DD + +,<,?,? @  ! ! ( ()9)<)< =#&& &#"&"9"9++&*&E&E 3    ?FWZZ  ::88 8wzzl+,,  7HPW6X'' 3zzr#c`||jvry|j|}|j}|j|j|jj t d||j|j|=|js|jjyy)N)r2r,r.) rr,request_script_stopdisconnect_file_watchersrsaver r.rclear)r session_idactive_session_infor,s r!disconnect_sessionz*WebsocketSessionManager.disconnect_session}s 88 8"&"A"A*"M )11G  ' ' )  , , .  ! ! & &#%8%I%I // ;..    $ $ &/r#c8|jj|Sr)rr*rr<s r!get_active_session_infoz/WebsocketSessionManager.get_active_session_infos..22:>>r#c||jvSr)rr@s r!is_active_sessionz)WebsocketSessionManager.is_active_sessionsT<<<rArCrHrKrMrPr#r!rr's K' K 3 K" K $= K  K(+/*. ;; ;0 ; ( ; ( ; ;z'*?=>, 5  r#rN) __future__rtypingrrrstreamlit.loggerrstreamlit.runtime.app_sessionr!streamlit.runtime.session_managerr r r r r collections.abcrstreamlit.runtime.script_datar+streamlit.runtime.scriptrunner.script_cacher'streamlit.runtime.uploaded_file_managerrrVr__annotations__rrZr#r!resN#--'4(8GKH%%N nN r#