Stop checkconnections with connectionserver

This commit is contained in:
shortcutme 2020-02-07 16:38:42 +01:00
parent 8e79a7da63
commit 6d425f30fe
No known key found for this signature in database
GPG Key ID: 5B63BAE6CB9613AE
1 changed files with 8 additions and 2 deletions

View File

@ -47,6 +47,7 @@ class ConnectionServer(object):
self.stream_server_proxy = None
self.running = False
self.stopping = False
self.thread_checker = None
self.stat_recv = defaultdict(lambda: defaultdict(int))
self.stat_sent = defaultdict(lambda: defaultdict(int))
@ -111,11 +112,14 @@ class ConnectionServer(object):
except Exception as err:
self.log.info("StreamServer listen error: %s" % err)
return False
self.log.debug("Stopped.")
def stop(self):
self.log.debug("Stopping")
self.log.debug("Stopping %s" % self.stream_server)
self.stopping = True
self.running = False
if self.thread_checker:
gevent.kill(self.thread_checker)
if self.stream_server:
self.stream_server.stop()
@ -244,9 +248,9 @@ class ConnectionServer(object):
def checkConnections(self):
run_i = 0
time.sleep(15)
while self.running:
run_i += 1
time.sleep(15) # Check every minute
self.ip_incoming = {} # Reset connected ips counter
last_message_time = 0
s = time.time()
@ -323,6 +327,8 @@ class ConnectionServer(object):
if time.time() - s > 0.01:
self.log.debug("Connection cleanup in %.3fs" % (time.time() - s))
time.sleep(15)
self.log.debug("Checkconnections ended")
@util.Noparallel(blocking=False)