Stop existing threads

main
Bob Mottram 2020-02-19 12:27:21 +00:00
parent 0277b309d9
commit 4019814a05
2 changed files with 79 additions and 2 deletions

View File

@ -77,6 +77,9 @@ from theme import setCSSparam
testServerAliceRunning = False testServerAliceRunning = False
testServerBobRunning = False testServerBobRunning = False
testServerEveRunning = False testServerEveRunning = False
thrAlice=None
thrBob=None
thrEve=None
def testHttpsigBase(withDigest): def testHttpsigBase(withDigest):
print('testHttpsig(' + str(withDigest) + ')') print('testHttpsig(' + str(withDigest) + ')')
@ -361,11 +364,26 @@ def testPostMessageBetweenServers():
aliceSendThreads=[] aliceSendThreads=[]
bobSendThreads=[] bobSendThreads=[]
global thrAlice
if thrAlice:
while thrAlice.isAlive():
thrAlice.stop()
time.sleep(1)
thrAlice.kill()
thrAlice = \ thrAlice = \
threadWithTrace(target=createServerAlice, \ threadWithTrace(target=createServerAlice, \
args=(aliceDir,aliceDomain,alicePort, \ args=(aliceDir,aliceDomain,alicePort, \
federationList,False,False, \ federationList,False,False, \
ocapAlways,aliceSendThreads),daemon=True) ocapAlways,aliceSendThreads),daemon=True)
global thrBob
if thrBob:
while thrBob.isAlive():
thrBob.stop()
time.sleep(1)
thrBob.kill()
thrBob = \ thrBob = \
threadWithTrace(target=createServerBob, \ threadWithTrace(target=createServerBob, \
args=(bobDir,bobDomain,bobPort, \ args=(bobDir,bobDomain,bobPort, \
@ -556,6 +574,14 @@ def testFollowBetweenServersWithCapabilities():
aliceDomain='127.0.0.42' aliceDomain='127.0.0.42'
alicePort=61935 alicePort=61935
aliceSendThreads=[] aliceSendThreads=[]
global thrAlice
if thrAlice:
while thrAlice.isAlive():
thrAlice.stop()
time.sleep(1)
thrAlice.kill()
thrAlice = \ thrAlice = \
threadWithTrace(target=createServerAlice, \ threadWithTrace(target=createServerAlice, \
args=(aliceDir,aliceDomain,alicePort, \ args=(aliceDir,aliceDomain,alicePort, \
@ -566,6 +592,14 @@ def testFollowBetweenServersWithCapabilities():
bobDomain='127.0.0.64' bobDomain='127.0.0.64'
bobPort=61936 bobPort=61936
bobSendThreads=[] bobSendThreads=[]
global thrBob
if thrBob:
while thrBob.isAlive():
thrBob.stop()
time.sleep(1)
thrBob.kill()
thrBob = \ thrBob = \
threadWithTrace(target=createServerBob, \ threadWithTrace(target=createServerBob, \
args=(bobDir,bobDomain,bobPort, \ args=(bobDir,bobDomain,bobPort, \
@ -576,6 +610,13 @@ def testFollowBetweenServersWithCapabilities():
eveDomain='127.0.0.55' eveDomain='127.0.0.55'
evePort=61937 evePort=61937
eveSendThreads=[] eveSendThreads=[]
global thrEve
if thrEve:
while thrEve.isAlive():
thrEve.stop()
time.sleep(1)
thrEve.kill()
thrEve = \ thrEve = \
threadWithTrace(target=createServerEve, \ threadWithTrace(target=createServerEve, \
args=(eveDir,eveDomain,evePort, \ args=(eveDir,eveDomain,evePort, \
@ -838,6 +879,14 @@ def testFollowBetweenServers():
aliceDomain='127.0.0.42' aliceDomain='127.0.0.42'
alicePort=61935 alicePort=61935
aliceSendThreads=[] aliceSendThreads=[]
global thrAlice
if thrAlice:
while thrAlice.isAlive():
thrAlice.stop()
time.sleep(1)
thrAlice.kill()
thrAlice = \ thrAlice = \
threadWithTrace(target=createServerAlice, \ threadWithTrace(target=createServerAlice, \
args=(aliceDir,aliceDomain,alicePort, \ args=(aliceDir,aliceDomain,alicePort, \
@ -848,6 +897,14 @@ def testFollowBetweenServers():
bobDomain='127.0.0.64' bobDomain='127.0.0.64'
bobPort=61936 bobPort=61936
bobSendThreads=[] bobSendThreads=[]
global thrBob
if thrBob:
while thrBob.isAlive():
thrBob.stop()
time.sleep(1)
thrBob.kill()
thrBob = \ thrBob = \
threadWithTrace(target=createServerBob, \ threadWithTrace(target=createServerBob, \
args=(bobDir,bobDomain,bobPort, \ args=(bobDir,bobDomain,bobPort, \
@ -1286,6 +1343,14 @@ def testClientToServer():
aliceDomain='127.0.0.42' aliceDomain='127.0.0.42'
alicePort=61935 alicePort=61935
aliceSendThreads=[] aliceSendThreads=[]
global thrAlice
if thrAlice:
while thrAlice.isAlive():
thrAlice.stop()
time.sleep(1)
thrAlice.kill()
thrAlice = \ thrAlice = \
threadWithTrace(target=createServerAlice, \ threadWithTrace(target=createServerAlice, \
args=(aliceDir,aliceDomain,alicePort, \ args=(aliceDir,aliceDomain,alicePort, \
@ -1296,6 +1361,14 @@ def testClientToServer():
bobDomain='127.0.0.64' bobDomain='127.0.0.64'
bobPort=61936 bobPort=61936
bobSendThreads=[] bobSendThreads=[]
global thrBob
if thrBob:
while thrBob.isAlive():
thrBob.stop()
time.sleep(1)
thrBob.kill()
thrBob = \ thrBob = \
threadWithTrace(target=createServerBob, \ threadWithTrace(target=createServerBob, \
args=(bobDir,bobDomain,bobPort, \ args=(bobDir,bobDomain,bobPort, \

View File

@ -7,6 +7,7 @@ __email__ = "bob@freedombone.net"
__status__ = "Production" __status__ = "Production"
import threading import threading
import os
import sys import sys
import trace import trace
import time import time
@ -134,5 +135,8 @@ def removeDormantThreads(baseDir: str,threadsList: [],debug: bool) -> None:
if debug: if debug:
sendLogFilename=baseDir+'/send.csv' sendLogFilename=baseDir+'/send.csv'
try:
with open(sendLogFilename, "a+") as logFile: with open(sendLogFilename, "a+") as logFile:
logFile.write(currTime.strftime("%Y-%m-%dT%H:%M:%SZ")+','+str(noOfActiveThreads)+','+str(len(threadsList))+'\n') logFile.write(currTime.strftime("%Y-%m-%dT%H:%M:%SZ")+','+str(noOfActiveThreads)+','+str(len(threadsList))+'\n')
except:
pass