You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After configuring sqlalchemy-utils' unit tests to escalate warnings to errors, it was revealed that the root cause of a ResourceWarning was a socket that is opened in pg8000.core.CoreConnection.__init__() but is not closed when an error is detected:
Python's garbage collector will eventually collect the socket object and throw a ResourceWarning. I have tested and found that calling self.close() immediately prior to raising self.error will resolve this problem.
Thanks for this bug report and patch @kurtmckee. I've used your PR and done a new release (1.24.2). I hadn't thought about the fact that if there's an exception in a constructor, there's no handle on the object and so resources associated with it can't be freed.
After configuring sqlalchemy-utils' unit tests to escalate warnings to errors, it was revealed that the root cause of a ResourceWarning was a socket that is opened in
pg8000.core.CoreConnection.__init__()
but is not closed when an error is detected:pg8000/pg8000/core.py
Lines 341 to 342 in 121f754
Python's garbage collector will eventually collect the socket object and throw a ResourceWarning. I have tested and found that calling
self.close()
immediately prior to raisingself.error
will resolve this problem.This is related to kvesteri/sqlalchemy-utils#590.
The text was updated successfully, but these errors were encountered: