forked from indymedia/epicyon
				
			Restart the inbox queue when full
							parent
							
								
									2af1b5cb3b
								
							
						
					
					
						commit
						c79efe6d6f
					
				
							
								
								
									
										13
									
								
								daemon.py
								
								
								
								
							
							
						
						
									
										13
									
								
								daemon.py
								
								
								
								
							|  | @ -790,6 +790,12 @@ class PubServer(BaseHTTPRequestHandler): | |||
|                           messageBytes: str) -> int: | ||||
|         """Update the inbox queue | ||||
|         """ | ||||
|         if self.server.restartInboxQueueInProgress: | ||||
|             self._503() | ||||
|             print('Message arrrived but currently restarting inbox queue') | ||||
|             self.server.POSTbusy = False | ||||
|             return 2 | ||||
| 
 | ||||
|         # check for blocked domains so that they can be rejected early | ||||
|         messageDomain = None | ||||
|         if messageJson.get('actor'): | ||||
|  | @ -810,6 +816,8 @@ class PubServer(BaseHTTPRequestHandler): | |||
|                 print('Queue: Inbox queue is full') | ||||
|             self._503() | ||||
|             self.server.POSTbusy = False | ||||
|             if not restartInboxQueueInProgress: | ||||
|                 self.server.restartInboxQueue=True | ||||
|             return 2 | ||||
| 
 | ||||
|         # Convert the headers needed for signature verification to dict | ||||
|  | @ -7258,6 +7266,11 @@ def runDaemon(blogsInstance: bool, mediaInstance: bool, | |||
|     httpd.thrPostSchedule = \ | ||||
|         threadWithTrace(target=runPostSchedule, | ||||
|                         args=(baseDir, httpd, 20), daemon=True) | ||||
| 
 | ||||
|     # flags used when restarting the inbox queue | ||||
|     httpd.restartInboxQueueInProgress=False | ||||
|     httpd.restartInboxQueue=False | ||||
| 
 | ||||
|     if not unitTest: | ||||
|         print('Creating inbox queue watchdog') | ||||
|         httpd.thrWatchdog = \ | ||||
|  |  | |||
							
								
								
									
										6
									
								
								inbox.py
								
								
								
								
							
							
						
						
									
										6
									
								
								inbox.py
								
								
								
								
							|  | @ -2185,11 +2185,15 @@ def runInboxQueueWatchdog(projectVersion: str, httpd) -> None: | |||
|     httpd.thrInboxQueue.start() | ||||
|     while True: | ||||
|         time.sleep(20) | ||||
|         if not httpd.thrInboxQueue.isAlive(): | ||||
|         if not httpd.thrInboxQueue.isAlive() or httpd.restartInboxQueue: | ||||
|             httpd.restartInboxQueueInProgress=True | ||||
|             httpd.thrInboxQueue.kill() | ||||
|             httpd.thrInboxQueue = inboxQueueOriginal.clone(runInboxQueue) | ||||
|             httpd.inboxQueue.clear() | ||||
|             httpd.thrInboxQueue.start() | ||||
|             print('Restarting inbox queue...') | ||||
|             httpd.restartInboxQueueInProgress=False | ||||
|             httpd.restartInboxQueue=False | ||||
| 
 | ||||
| 
 | ||||
| def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int, | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue