Skip to content

Commit 230642d

Browse files
committed
Fix session disconnects
1 parent 6933b50 commit 230642d

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

brain/api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def _new_session(self):
5858
"sec-fetch-mode": "cors",
5959
"sec-fetch-site": "same-site",
6060
"Referer": "https://platform.worldquantbrain.com/",
61+
"connection": "keep-alive",
62+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",
6163
}
6264
)
6365
self._authenticate()

brain/search_algorithm.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ def monitor_alpha(response, alpha_config):
106106
)
107107
except Exception as e:
108108
print(f"Error during obtaining results: {e}")
109-
# TODO: Remote end closed connection without response
110-
# Need to refresh session
109+
if isinstance(e, (ConnectionError)):
110+
BrainAPI._new_session()
111+
111112
return {
112113
"alpha_id": None,
113114
"simulate_data": alpha_config,

0 commit comments

Comments
 (0)