| 88 | self._task_queue.put([args_to_put, kwargs]) |
| 89 | |
| 90 | def get(self): |
| 91 | import sys |
| 92 | self._task_queue.put(None) |
| 93 | self._finished = True # Mark as finished |
| 94 | thread = self._worker_thread |
| 95 | try: |
| 96 | # Must see https://stackoverflow.com/questions/4136632/how-to-kill-a-child-thread-with-ctrlc |
| 97 | while thread.is_alive(): |
| 98 | thread.join(0.1) |
| 99 | except KeyboardInterrupt: |
| 100 | sys.exit(1) |
| 101 | self._task_queue.join() |
| 102 | |
| 103 | return flatten(self.result_list) |
| 104 | |
| 105 | def run_parallel(run, ls, n_workers, use_threads): |
| 106 | from joblib import Parallel, delayed |