Use ThreadingHTTPServer instead of own threaded HTTPServer

This commit is contained in:
croneter 2021-10-18 15:48:44 +02:00
parent 8c64e2a17c
commit f3754fa2e3
2 changed files with 4 additions and 10 deletions

View file

@ -300,7 +300,7 @@ class PlexCompanion(backgroundthread.KillableThread):
start_count = 0 start_count = 0
while True: while True:
try: try:
httpd = listener.ThreadedHTTPServer( httpd = listener.PKCHTTPServer(
client, client,
subscription_manager, subscription_manager,
('', v.COMPANION_PORT), ('', v.COMPANION_PORT),

View file

@ -5,8 +5,7 @@ Plex Companion listener
""" """
from logging import getLogger from logging import getLogger
from re import sub from re import sub
from socketserver import ThreadingMixIn from http.server import ThreadingHTTPServer, BaseHTTPRequestHandler
from http.server import HTTPServer, BaseHTTPRequestHandler
from .. import utils, companion, json_rpc as js, clientinfo, variables as v from .. import utils, companion, json_rpc as js, clientinfo, variables as v
from .. import app from .. import app
@ -227,12 +226,7 @@ class MyHandler(BaseHTTPRequestHandler):
self.response(v.COMPANION_OK_MESSAGE, headers) self.response(v.COMPANION_OK_MESSAGE, headers)
class ThreadedHTTPServer(ThreadingMixIn, HTTPServer): class PKCHTTPServer(ThreadingHTTPServer):
"""
Using ThreadingMixIn Thread magic
"""
daemon_threads = True
def __init__(self, client, subscription_manager, *args, **kwargs): def __init__(self, client, subscription_manager, *args, **kwargs):
""" """
client: Class handle to plexgdm.plexgdm. We can thus ask for an up-to- 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.client = client
self.subscription_manager = subscription_manager self.subscription_manager = subscription_manager
HTTPServer.__init__(self, *args, **kwargs) super().__init__(*args, **kwargs)