Skip to content

Commit

Permalink
Fix unbound local variable error
Browse files Browse the repository at this point in the history
If the call to open stdout or stderr files, the corresponding variable will be unbound and result in an error.
  • Loading branch information
jdidion authored May 29, 2024
1 parent f295bea commit e5f06c9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pytest_workflow/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def start(self):
# is started from multiple threads.
with self.start_lock:
if not self._started:
stdout_h = None
stderr_h = None
try:
stdout_h = self.stdout_file.open('wb')
stderr_h = self.stderr_file.open('wb')
Expand All @@ -91,8 +93,10 @@ def start(self):
self.errors.append(error)
finally:
self._started = True
stdout_h.close()
stderr_h.close()
if stdout_h is not None:
stdout_h.close()
if stderr_h is not None:
stderr_h.close()
else:
raise ValueError("Workflows can only be started once")

Expand Down

0 comments on commit e5f06c9

Please sign in to comment.