Skip to content

Commit 26042a2

Browse files
committed
added information if scan method fails
1 parent 93e1275 commit 26042a2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/fastcs/backend.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,18 @@ def _run_initial_tasks(self):
5353
future.result()
5454

5555
def _start_scan_tasks(self):
56-
scan_tasks = _get_scan_tasks(self._mapping)
57-
58-
for task in scan_tasks:
59-
asyncio.run_coroutine_threadsafe(task(), self._loop)
56+
async def run_tasks():
57+
futures = [task() for task in _get_scan_tasks(self._mapping)]
58+
for future in asyncio.as_completed(futures):
59+
try:
60+
await future
61+
except Exception as e:
62+
# We don't exit the ioc when a scan loop errors,
63+
# but we do print the information.
64+
print(f"Scan loop stopped with exception:\n {e}")
65+
raise e
66+
67+
asyncio.run_coroutine_threadsafe(run_tasks(), self._loop)
6068

6169
def _run(self):
6270
raise NotImplementedError("Specific Backend must implement _run")

0 commit comments

Comments
 (0)