Skip to content

Commit c18114d

Browse files
committed
BUG: Make sure that raised exceptions abort queued cells
1 parent 9aba3d9 commit c18114d

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

itkwidgets/cell_watcher.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,16 +294,19 @@ def update_namespace(self) -> None:
294294
"""Update the namespace variables with the results from the getters"""
295295
# FIXME: This is a temporary "fix" and does not handle updating output
296296
keys = [k for k in self.shell.user_ns.keys()]
297-
for key in keys:
298-
value = self.shell.user_ns[key]
299-
if asyncio.isfuture(value) and (
300-
isinstance(value, FuturePromise) or isinstance(value, asyncio.Task)
301-
):
302-
# Functions that need to return values from asynchronous
303-
# network requests return futures. They should all be resolved
304-
# now, so use the result.
305-
self.shell.user_ns[key] = value.result()
306-
self.results.clear()
297+
try:
298+
for key in keys:
299+
value = self.shell.user_ns[key]
300+
if asyncio.isfuture(value) and (isinstance(value, FuturePromise) or isinstance(value, asyncio.Task)):
301+
# Getters/setters return futures
302+
# They should all be resolved now, so use the result
303+
self.shell.user_ns[key] = value.result()
304+
self.results.clear()
305+
except Exception as e:
306+
self.results.clear()
307+
self.abort_all = True
308+
self.create_task(self._execute_next_request)
309+
raise e
307310

308311
def _callback(self, *args, **kwargs) -> None:
309312
"""After each future resolves check to see if they are all resolved. If

0 commit comments

Comments
 (0)