Skip to content

Commit

Permalink
[pyright] [core] _cli/api (#11697)
Browse files Browse the repository at this point in the history
### Summary & Motivation

Just massages some logic in `_cli/api` to fix a type error where some
variables were accessed (`cancellation_thread`) without them having a
guaranteed binding.

### How I Tested These Changes

BK
  • Loading branch information
smackesey committed Jan 16, 2023
1 parent 2b77726 commit 9c8a31f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python_modules/dagster/dagster/_cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def _execute_run_command_body(
cancellation_thread, cancellation_thread_shutdown_event = start_run_cancellation_thread(
instance, pipeline_run_id
)
else:
cancellation_thread, cancellation_thread_shutdown_event = None, None

pipeline_run: DagsterRun = check.not_none(
instance.get_run_by_id(pipeline_run_id),
Expand Down Expand Up @@ -135,6 +137,8 @@ def _execute_run_command_body(
run_worker_failed = True
finally:
if instance.should_start_background_run_thread:
cancellation_thread_shutdown_event = check.not_none(cancellation_thread_shutdown_event)
cancellation_thread = check.not_none(cancellation_thread)
cancellation_thread_shutdown_event.set()
if cancellation_thread.is_alive():
cancellation_thread.join(timeout=15)
Expand Down Expand Up @@ -198,6 +202,8 @@ def _resume_run_command_body(
cancellation_thread, cancellation_thread_shutdown_event = start_run_cancellation_thread(
instance, pipeline_run_id
)
else:
cancellation_thread, cancellation_thread_shutdown_event = None, None
pipeline_run = check.not_none(
instance.get_run_by_id(pipeline_run_id), # type: ignore
"Pipeline run with id '{}' not found for run execution.".format(pipeline_run_id),
Expand Down Expand Up @@ -238,6 +244,8 @@ def _resume_run_command_body(
run_worker_failed = True
finally:
if instance.should_start_background_run_thread:
cancellation_thread_shutdown_event = check.not_none(cancellation_thread_shutdown_event)
cancellation_thread = check.not_none(cancellation_thread)
cancellation_thread_shutdown_event.set()
if cancellation_thread.is_alive():
cancellation_thread.join(timeout=15)
Expand Down

0 comments on commit 9c8a31f

Please sign in to comment.