I'm running some unit tests with Python 3.6.1 and getting a ResourceWarning
ResourceWarning: unclosed <socket.socket fd=14, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 54897), raddr=('127.0.0.1', 11211)>
The port and area of code indicate it's memcached
, and I'm using python-memcached
1.5.8. Relevant code is here:
if use_caching:
import memcache
mc = memcache.Client(['127.0.0.1:11211'], debug=0)
key = 'descendent-catalog-ids-{0}'.format(str(cat_id))
catalog_ids = mc.get(key)
if catalog_ids is None:
catalog_ids = get_descendent_ids(hierarchy_session)
mc.set(key, catalog_ids)
else:
catalog_ids = get_descendent_ids(hierarchy_session)
Am I supposed to manually close the memcached Client
instance somehow? I can't find any reference in the source code or docs about manually closing the socket, so I assumed that the library would handle that automagically...
I haven't found any similar questions (only one for urllib), and there aren't any relevant issues in GitHub, so my assumption is that I'm missing something simple.