dawoudt / JustWatchAPI

Python 3 JustWatch.com API - https://justwatch.com
MIT License
326 stars 45 forks source link

handle ResourceWarning: unclosed Warning #21

Closed dawoudt closed 5 years ago

dawoudt commented 5 years ago

While writing unit test i noticed this warning is displayed ...unittest/case.py:615: ResourceWarning: unclosed <ssl.SSLSocket fd=7, ...

This is due to the creation of a requests.Session() and not closing it. Although this is a warning, it would be nice to handle this with a context manager..

Something like:

with JustWatch(...) as j:
    results = j.search_for_item(...)

This would require handing creation and deletion of Session() in __enter__ and __exit__ respectively

@draogn thoughts?

dawoudt commented 5 years ago

implemented del.. Should really be a context manager though