Skip to content

Commit

Permalink
print error information from scan method
Browse files Browse the repository at this point in the history
  • Loading branch information
evalott100 committed Nov 11, 2024
1 parent 93e1275 commit f2554b1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/fastcs/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,18 @@ def _run_initial_tasks(self):
future.result()

def _start_scan_tasks(self):
scan_tasks = _get_scan_tasks(self._mapping)

for task in scan_tasks:
asyncio.run_coroutine_threadsafe(task(), self._loop)
async def run_tasks():
futures = [task() for task in _get_scan_tasks(self._mapping)]
for future in asyncio.as_completed(futures):
try:
await future
except Exception as e:
# We don't exit the ioc when a scan loop errors,
# but we do print the information.
print(f"Scan loop stopped with exception:\n {e}")
raise e

asyncio.run_coroutine_threadsafe(run_tasks(), self._loop)

def _run(self):
raise NotImplementedError("Specific Backend must implement _run")
Expand Down

0 comments on commit f2554b1

Please sign in to comment.