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

Fix unbound local variable error #197

Merged
merged 1 commit into from
Jun 4, 2024
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
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
Loading