From 7963bc56ea2e2ec30c783739f7baae4391d75db4 Mon Sep 17 00:00:00 2001 From: Fierelier Date: Wed, 14 Apr 2021 05:12:49 +0200 Subject: [PATCH] Add thread counter debugger --- fstream-server.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fstream-server.py b/fstream-server.py index 39f08e6..1d44280 100644 --- a/fstream-server.py +++ b/fstream-server.py @@ -182,11 +182,29 @@ class inThread(threading.Thread): self.closeThread() raise +class debugThread(threading.Thread): + def __init__(self): + threading.Thread.__init__(self) + + def run(self): + while True: + with threadsLock: + print("Threads - IN: " +str(len(inThreads))) + print("Threads - OUT: " +str(len(outThreads))) + time.sleep(10) + def main(): global threadId serverSocket.bind(serverAddr) serverSocket.listen(1024) + # DEBUG + global time + import time + debug = debugThread() + debug.start() + # DEBUG END + while True: connection, address = serverSocket.accept() connection.settimeout(15)