-
Notifications
You must be signed in to change notification settings - Fork 331
Closed
Description
When I run the following python code with a debugger attached -
polygon_api = polygon.RESTClient()
response = polygon_api.stocks_equities_aggregates('AAPL', 30, 'minute', '2020-06-30', '2020-06-30')
I get a post-run warning from my debugger -
ResourceWarning: unclosed <ssl.SSLSocket type=SocketKind.SOCK_STREAM, raddr=('38.133.177.84', 443)>
But if I run -
polygon_api = polygon.RESTClient()
response = polygon_api.stocks_equities_aggregates('AAPL', 30, 'minute', '2020-06-30', '2020-06-30')
polygon_api._session.close()
The polygon client cleans up and my debugger is happy.
Looking into why this is, Session will only call its own close() from its __exit__ method, which is only called if the class is being used as a context manager (e.g. using with Session() as s: statement, as suggested by their docs) - and RESTClient is not using it in this manner, so close() is just never being called and resources are being left open.
Metadata
Metadata
Assignees
Labels
No labels