1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-17 17:42:20 +03:00

plugins/edsm: Call requests.Session.close() after we've shutdown worker thread

This properly closes any sockets and avoids a -W default warning on
shutdown.
This commit is contained in:
Athanasius 2021-03-09 15:12:16 +00:00
parent d7d3dc19e4
commit 3d3674da5f

View File

@ -168,6 +168,7 @@ def plugin_stop() -> None:
this.queue.put(None)
this.thread.join()
this.thread = None
this.session.close()
# Suppress 'Exception ignored in: <function Image.__del__ at ...>' errors # TODO: this is bad.
this._IMG_KNOWN = this._IMG_UNKNOWN = this._IMG_NEW = this._IMG_ERROR = None
logger.debug('Done.')
@ -541,7 +542,6 @@ def worker() -> None:
r = this.session.get('https://www.edsm.net/api-journal-v1/discard', timeout=_TIMEOUT)
r.raise_for_status()
this.discardedEvents = set(r.json())
r.close()
this.discardedEvents.discard('Docked') # should_send() assumes that we send 'Docked' events
if not this.discardedEvents: