def terminate(self):
if not self.join_signal.is_set():<EOL><INDENT>self.join_signal.set()<EOL><DEDENT>time.sleep(<NUM_LIT>)<EOL>if self.main_worker_thread.is_alive():<EOL><INDENT>self.main_worker_thread.join()<EOL><DEDENT>if self.threaded:<EOL><INDENT>for worker in self.workers:<EOL><INDENT>if worker.is_alive():<EOL><INDENT>worker.join()<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for worker in self.workers:<EOL><INDENT>if worker.is_alive():<EOL><INDENT>worker.terminate()<EOL>worker.join()<EOL><DEDENT><DEDENT>while not self.all_finished():<EOL><INDENT>time.sleep(<NUM_LIT>)<EOL><DEDENT><DEDENT>if self.queue.full():<EOL><INDENT>self.queue.get()<EOL><DEDENT>self.queue.put(pickle.dumps(None, protocol=-<NUM_LIT:1>))<EOL>time.sleep(<NUM_LIT>)<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>self._queue_internal.get(timeout=<NUM_LIT>)<EOL><DEDENT>except QueueEmpty:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if not self._queue_internal._closed:<EOL><INDENT>self._queue_internal.close()<EOL><DEDENT>if not self.queue._closed:<EOL><INDENT>self.queue.close()<EOL><DEDENT>self._queue_internal.join_thread()<EOL>self.queue.join_thread()<EOL>time.sleep(<NUM_LIT>)<EOL>
Stop all workers.