diff --git a/daemon.py b/daemon.py index e311828a0..36b77cdc3 100644 --- a/daemon.py +++ b/daemon.py @@ -21,6 +21,7 @@ from person import personKeyLookup from person import personOutboxJson from inbox import inboxPermittedMessage from follow import getFollowingFeed +from threads import testThreads import os import sys @@ -220,6 +221,7 @@ def runDaemon(domain: str,port=80,fedList=[],useTor=False) -> None: print('Running tests...') testHttpsig() testCache() + testThreads() print('Tests succeeded\n') serverAddress = ('', port) diff --git a/threads.py b/threads.py index 2dc6609b4..4a6323b76 100644 --- a/threads.py +++ b/threads.py @@ -9,6 +9,7 @@ __status__ = "Production" import threading import sys import trace +import time class threadWithTrace(threading.Thread): def __init__(self, *args, **keywords): @@ -39,3 +40,17 @@ class threadWithTrace(threading.Thread): def kill(self): self.killed = True + +def testThreadsFunction(param: str): + for i in range(10000): + time.sleep(2) + +def testThreads(): + print('testThreads') + thr = threadWithTrace(target=testThreadsFunction,args=('test',),daemon=True) + thr.start() + assert thr.isAlive()==True + time.sleep(1) + thr.kill() + thr.join() + assert thr.isAlive()==False