From f3754fa2e323fc3b6582c839f1fa46da9fbb3939 Mon Sep 17 00:00:00 2001 From: croneter Date: Mon, 18 Oct 2021 15:48:44 +0200 Subject: [PATCH] Use ThreadingHTTPServer instead of own threaded HTTPServer --- resources/lib/plex_companion.py | 2 +- resources/lib/plexbmchelper/listener.py | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/resources/lib/plex_companion.py b/resources/lib/plex_companion.py index 25cf12aa..fb55a637 100644 --- a/resources/lib/plex_companion.py +++ b/resources/lib/plex_companion.py @@ -300,7 +300,7 @@ class PlexCompanion(backgroundthread.KillableThread): start_count = 0 while True: try: - httpd = listener.ThreadedHTTPServer( + httpd = listener.PKCHTTPServer( client, subscription_manager, ('', v.COMPANION_PORT), diff --git a/resources/lib/plexbmchelper/listener.py b/resources/lib/plexbmchelper/listener.py index f89a9e23..1b6ce3a3 100644 --- a/resources/lib/plexbmchelper/listener.py +++ b/resources/lib/plexbmchelper/listener.py @@ -5,8 +5,7 @@ Plex Companion listener """ from logging import getLogger from re import sub -from socketserver import ThreadingMixIn -from http.server import HTTPServer, BaseHTTPRequestHandler +from http.server import ThreadingHTTPServer, BaseHTTPRequestHandler from .. import utils, companion, json_rpc as js, clientinfo, variables as v from .. import app @@ -227,12 +226,7 @@ class MyHandler(BaseHTTPRequestHandler): self.response(v.COMPANION_OK_MESSAGE, headers) -class ThreadedHTTPServer(ThreadingMixIn, HTTPServer): - """ - Using ThreadingMixIn Thread magic - """ - daemon_threads = True - +class PKCHTTPServer(ThreadingHTTPServer): def __init__(self, client, subscription_manager, *args, **kwargs): """ client: Class handle to plexgdm.plexgdm. We can thus ask for an up-to- @@ -242,4 +236,4 @@ class ThreadedHTTPServer(ThreadingMixIn, HTTPServer): """ self.client = client self.subscription_manager = subscription_manager - HTTPServer.__init__(self, *args, **kwargs) + super().__init__(*args, **kwargs)