Skip to content

Commit 9d896fa

Browse files
committed
Catch case when not reconnected after instrument server goes down
1 parent 2c378c5 commit 9d896fa

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
@@ -456,14 +456,17 @@ async def get_rsyncer_info(
456456
select(RsyncInstance).where(RsyncInstance.session_id == session_id)
457457
).all()
458458
if machine_config.instrument_server_url:
459-
async with lock:
460-
token = instrument_server_tokens[session_id]["access_token"]
461-
async with aiohttp.ClientSession() as clientsession:
462-
async with clientsession.get(
463-
f"{machine_config.instrument_server_url}/sessions/{sanitise(str(session_id))}/rsyncer_info",
464-
headers={"Authorization": f"Bearer {token}"},
465-
) as resp:
466-
data = await resp.json()
459+
try:
460+
async with lock:
461+
token = instrument_server_tokens[session_id]["access_token"]
462+
async with aiohttp.ClientSession() as clientsession:
463+
async with clientsession.get(
464+
f"{machine_config.instrument_server_url}/sessions/{sanitise(str(session_id))}/rsyncer_info",
465+
headers={"Authorization": f"Bearer {token}"},
466+
) as resp:
467+
data = await resp.json()
468+
except KeyError:
469+
data = []
467470
combined_data = []
468471
data_source_lookup = {d["source"]: d for d in data}
469472
for ri in rsync_instances:

0 commit comments

Comments
 (0)