| 197 | ("ThreadPoolExecutor-%d" % self._counter())) |
| 198 | |
| 199 | def submit(self, fn, /, *args, **kwargs): |
| 200 | with self._shutdown_lock, _global_shutdown_lock: |
| 201 | if self._broken: |
| 202 | raise self.BROKEN(self._broken) |
| 203 | |
| 204 | if self._shutdown: |
| 205 | raise RuntimeError('cannot schedule new futures after shutdown') |
| 206 | if _shutdown: |
| 207 | raise RuntimeError('cannot schedule new futures after ' |
| 208 | 'interpreter shutdown') |
| 209 | |
| 210 | f = _base.Future() |
| 211 | task = self._resolve_work_item_task(fn, args, kwargs) |
| 212 | w = _WorkItem(f, task) |
| 213 | |
| 214 | self._work_queue.put(w) |
| 215 | self._adjust_thread_count() |
| 216 | return f |
| 217 | submit.__doc__ = _base.Executor.submit.__doc__ |
| 218 | |
| 219 | def _adjust_thread_count(self): |