forked from indymedia/epicyon
Remove excess threads
parent
833d282888
commit
9fd8ed4c2e
15
daemon.py
15
daemon.py
|
@ -484,6 +484,13 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.followersThreads.remove(th)
|
self.server.followersThreads.remove(th)
|
||||||
if self.server.debug:
|
if self.server.debug:
|
||||||
print('DEBUG: '+str(len(self.server.followersThreads))+' followers threads active')
|
print('DEBUG: '+str(len(self.server.followersThreads))+' followers threads active')
|
||||||
|
# retain up to 20 threads
|
||||||
|
if len(self.server.followersThreads)>20:
|
||||||
|
# kill the thread if it is still alive
|
||||||
|
if self.server.followersThreads[0].is_alive():
|
||||||
|
self.server.followersThreads[0].kill()
|
||||||
|
# remove it from the list
|
||||||
|
self.server.followersThreads.pop(0)
|
||||||
# create a thread to send the post to followers
|
# create a thread to send the post to followers
|
||||||
followersThread= \
|
followersThread= \
|
||||||
sendToFollowersThread(self.server.session, \
|
sendToFollowersThread(self.server.session, \
|
||||||
|
@ -500,14 +507,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
messageJson,self.server.debug, \
|
messageJson,self.server.debug, \
|
||||||
self.server.projectVersion)
|
self.server.projectVersion)
|
||||||
self.server.followersThreads.append(followersThread)
|
self.server.followersThreads.append(followersThread)
|
||||||
# retain up to 20 threads
|
|
||||||
if len(self.server.followersThreads)>20:
|
|
||||||
for i in range(2):
|
|
||||||
# kill the thread if it is still alive
|
|
||||||
if self.server.followersThreads[0].is_alive():
|
|
||||||
self.server.followersThreads[0].kill()
|
|
||||||
# remove it from the list
|
|
||||||
self.server.followersThreads.pop(0)
|
|
||||||
if self.server.debug:
|
if self.server.debug:
|
||||||
print('DEBUG: handle any unfollow requests')
|
print('DEBUG: handle any unfollow requests')
|
||||||
outboxUndoFollow(self.server.baseDir,messageJson,self.server.debug)
|
outboxUndoFollow(self.server.baseDir,messageJson,self.server.debug)
|
||||||
|
|
Loading…
Reference in New Issue