One outbox thread per child

master
Bob Mottram 2019-09-03 20:40:44 +01:00
parent 7398583907
commit 606e7841fd
1 changed files with 11 additions and 7 deletions

View File

@ -428,21 +428,25 @@ class PubServer(BaseHTTPRequestHandler):
def _postToOutboxThread(self,messageJson: {}) -> bool: def _postToOutboxThread(self,messageJson: {}) -> bool:
"""Creates a thread to send a post """Creates a thread to send a post
""" """
if self.server.outboxThread: accountOutboxThreadName=self.postToNickname
if not accountOutboxThreadName:
accountOutboxThreadName='*'
if self.server.outboxThread.get(accountOutboxThreadName):
print('Waiting for previous outbox thread to end') print('Waiting for previous outbox thread to end')
waitCtr=0 waitCtr=0
while self.server.outboxThread.isAlive() and waitCtr<5: while self.server.outboxThread[accountOutboxThreadName].isAlive() and waitCtr<8:
time.sleep(1) time.sleep(1)
waitCtr+=1 waitCtr+=1
if waitCtr>=5: if waitCtr>=8:
self.server.outboxThread.kill() self.server.outboxThread[accountOutboxThreadName].kill()
print('Creating outbox thread') print('Creating outbox thread')
self.server.outboxThread= \ self.server.outboxThread[accountOutboxThreadName]= \
threadWithTrace(target=self._postToOutbox, \ threadWithTrace(target=self._postToOutbox, \
args=(messageJson.copy(),__version__),daemon=True) args=(messageJson.copy(),__version__),daemon=True)
print('Starting outbox thread') print('Starting outbox thread')
self.server.outboxThread.start() self.server.outboxThread[accountOutboxThreadName].start()
return True return True
def _inboxQueueCleardown(self): def _inboxQueueCleardown(self):
@ -3312,7 +3316,7 @@ def runDaemon(projectVersion, \
httpd = ThreadingHTTPServer(serverAddress, PubServerUnitTest) httpd = ThreadingHTTPServer(serverAddress, PubServerUnitTest)
else: else:
httpd = ThreadingHTTPServer(serverAddress, PubServer) httpd = ThreadingHTTPServer(serverAddress, PubServer)
httpd.outboxThread=None httpd.outboxThread={}
httpd.projectVersion=projectVersion httpd.projectVersion=projectVersion
# max POST size of 30M # max POST size of 30M
httpd.maxPostLength=1024*1024*30 httpd.maxPostLength=1024*1024*30