From 3d3674da5f9764c597507151465670254f09ec26 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Tue, 9 Mar 2021 15:12:16 +0000 Subject: [PATCH] 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. --- plugins/edsm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/edsm.py b/plugins/edsm.py index a5006a9d..d82c0fc0 100644 --- a/plugins/edsm.py +++ b/plugins/edsm.py @@ -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: ' 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: