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

Close internal SelectConnection resources #1761

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ def run(self) -> None:

except Exception:
log.exception("%r Unhandled error; event loop stopped", self)

finally:
if self._mq_conn and self._mq_conn.ioloop:
self._mq_conn.ioloop.close()

self._stop_event.set()

log.debug("%r thread ends.", self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,16 @@ def run(self):
self._connection = self._connect()
self._event_watcher()
self._connection.ioloop.start()

except Exception:
logger.exception(
"%s Unhandled exception: shutting down connection.", self
)

finally:
if self._connection and self._connection.ioloop:
self._connection.ioloop.close()

self._stop_event.set()
logger.debug("%s Shutdown complete", self)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ def run(self):
self._connection.ioloop.start()
except Exception:
logger.exception("Failed to start subscriber")
finally:
if self._connection and self._connection.ioloop:
self._connection.ioloop.close()

def stop(self) -> None:
"""stop() is called by the parent to shutdown the subscriber"""
Expand Down
Loading