Skip to content

Commit

Permalink
Merge pull request #311 from horw/fix/close_port_when_exception
Browse files Browse the repository at this point in the history
fix: close serial port when exception
  • Loading branch information
hfudev authored Oct 9, 2024
2 parents 0cbd304 + fe71a78 commit c2e2d0f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pytest-embedded-serial/pytest_embedded_serial/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ def __init__(

self.ports_to_occupy.append(self.port)
self._post_init()
self._start()

try:
self._start()
except Exception as e:
self.close()
raise e
self._finalize_init()
if not stop_after_init:
self.start_redirect_thread()
Expand Down

0 comments on commit c2e2d0f

Please sign in to comment.