Skip to content

Commit 58129f9

Browse files
committed
Catch case when not reconnected after instrument server goes down
1 parent c3b5371 commit 58129f9

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/murfey/server/api/instrument.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,17 @@ async def get_rsyncer_info(
435435
select(RsyncInstance).where(RsyncInstance.session_id == session_id)
436436
).all()
437437
if machine_config.instrument_server_url:
438-
async with lock:
439-
token = instrument_server_tokens[session_id]["access_token"]
440-
async with aiohttp.ClientSession() as clientsession:
441-
async with clientsession.get(
442-
f"{machine_config.instrument_server_url}/sessions/{sanitise(str(session_id))}/rsyncer_info",
443-
headers={"Authorization": f"Bearer {token}"},
444-
) as resp:
445-
data = await resp.json()
438+
try:
439+
async with lock:
440+
token = instrument_server_tokens[session_id]["access_token"]
441+
async with aiohttp.ClientSession() as clientsession:
442+
async with clientsession.get(
443+
f"{machine_config.instrument_server_url}/sessions/{sanitise(str(session_id))}/rsyncer_info",
444+
headers={"Authorization": f"Bearer {token}"},
445+
) as resp:
446+
data = await resp.json()
447+
except KeyError:
448+
data = []
446449
combined_data = []
447450
data_source_lookup = {d["source"]: d for d in data}
448451
for ri in rsync_instances:

0 commit comments

Comments
 (0)