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

View File

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