Skip to content
This repository was archived by the owner on Jun 22, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion eel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
_eel_js = open(_eel_js_file, encoding='utf-8').read()
_websockets = []
_call_return_values = {}
_call_return_msgs = {}
_call_return_callbacks = {}
_call_number = 0
_exposed_functions = {}
Expand Down Expand Up @@ -305,6 +306,7 @@ def _process_message(message, ws):
elif message['status'] == 'error' and error_callback is not None:
error_callback(message['error'], message['stack'])
else:
_call_return_msgs[call_id] = message
_call_return_values[call_id] = message['value']

else:
Expand Down Expand Up @@ -353,12 +355,23 @@ def _call_return(call):

def return_func(callback=None, error_callback=None):
if callback is not None:
_call_return_callbacks[call_id] = (callback, error_callback)
if call_id in _call_return_msgs:
_call_return_values.pop(call_id)
message = _call_return_msgs.pop(call_id)
if message['status'] == 'ok':
callback(message['value'])
elif message['status'] == 'error' and error_callback is not None:
error_callback(message['error'], message['stack'])
else:
_call_return_callbacks[call_id] = (callback, error_callback)

else:
for w in range(_js_result_timeout):
if call_id in _call_return_values:
_call_return_msgs.pop(call_id, None)
return _call_return_values.pop(call_id)
sleep(0.001)

return return_func


Expand Down