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

Serial File Descriptor Not Closed When Error Occurs in Serial.__init__ (RDT-912) #307

Closed
horw opened this issue Sep 30, 2024 · 0 comments · Fixed by #311
Closed

Serial File Descriptor Not Closed When Error Occurs in Serial.__init__ (RDT-912) #307

horw opened this issue Sep 30, 2024 · 0 comments · Fixed by #311
Labels
bug Something isn't working

Comments

@horw
Copy link
Collaborator

horw commented Sep 30, 2024

Describe the bug

  res = None
  try:
      res = func(*args, **kwargs)
      yield res
  finally:
      if res:
          _close_or_terminate(res)

This part of the code only considers close_or_terminate when the object has already been created. However, if the object gets stuck in __init__, the serial file descriptor, for example, will never be closed. A similar bug may occur with other objects as well.

To Reproduce
Steps to reproduce the behavior:

  1. Raise any error in the self._start() function of the Serial class.
  2. self.proc will never be closed.

Expected behavior
All objects should be processed properly. If there is an exception, any opened resources should be closed.

@horw horw added the bug Something isn't working label Sep 30, 2024
@github-actions github-actions bot changed the title Serial File Descriptor Not Closed When Error Occurs in Serial.__init__ Serial File Descriptor Not Closed When Error Occurs in Serial.__init__ (RDT-912) Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant