Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Make sure that raised exceptions abort queued cells #721

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions itkwidgets/cell_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,19 @@ def update_namespace(self) -> None:
"""Update the namespace variables with the results from the getters"""
# FIXME: This is a temporary "fix" and does not handle updating output
keys = [k for k in self.shell.user_ns.keys()]
for key in keys:
value = self.shell.user_ns[key]
if asyncio.isfuture(value) and (
isinstance(value, FuturePromise) or isinstance(value, asyncio.Task)
):
# Functions that need to return values from asynchronous
# network requests return futures. They should all be resolved
# now, so use the result.
self.shell.user_ns[key] = value.result()
self.results.clear()
try:
for key in keys:
value = self.shell.user_ns[key]
if asyncio.isfuture(value) and (isinstance(value, FuturePromise) or isinstance(value, asyncio.Task)):
# Getters/setters return futures
# They should all be resolved now, so use the result
self.shell.user_ns[key] = value.result()
self.results.clear()
except Exception as e:
self.results.clear()
self.abort_all = True
self.create_task(self._execute_next_request)
raise e

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