(self)
| 43 | self.server = server |
| 44 | |
| 45 | def run(self): |
| 46 | while True: |
| 47 | kill_found = False |
| 48 | commands = [] |
| 49 | command = self.notifications_queue.get(block=True) |
| 50 | if isinstance(command, KillServer): |
| 51 | kill_found = True |
| 52 | else: |
| 53 | assert isinstance(command, ParallelNotification) |
| 54 | commands.append(command.to_tuple()) |
| 55 | |
| 56 | try: |
| 57 | while True: |
| 58 | command = self.notifications_queue.get(block=False) # No block to create a batch. |
| 59 | if isinstance(command, KillServer): |
| 60 | kill_found = True |
| 61 | else: |
| 62 | assert isinstance(command, ParallelNotification) |
| 63 | commands.append(command.to_tuple()) |
| 64 | except: |
| 65 | pass # That's OK, we're getting it until it becomes empty so that we notify multiple at once. |
| 66 | |
| 67 | if commands: |
| 68 | try: |
| 69 | # Batch notification. |
| 70 | self.server.lock.acquire() |
| 71 | try: |
| 72 | self.server.notifyCommands(self.job_id, commands) |
| 73 | finally: |
| 74 | self.server.lock.release() |
| 75 | except: |
| 76 | traceback.print_exc() |
| 77 | |
| 78 | if kill_found: |
| 79 | self.finished = True |
| 80 | return |
| 81 | |
| 82 | |
| 83 | # ======================================================================================================================= |
nothing calls this directly
no test coverage detected