MCPcopy Create free account
hub / github.com/brmmm3/fastthreadpool / _child

Method _child

fastthreadpool/fastthreadpool.py:332–394  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

330 self._failed_cnt.release()
331
332 def _child(self):
333 #c cdef bint run_child, pop_failed
334 self._busy_lock_inc()
335 child_busy = True
336 _done_append = self._done.append
337 jobs_popleft = self._jobs.popleft
338 run_child = True
339 pop_failed = False
340 job = None
341 args = None
342 kwargs = None
343 while run_child:
344 try:
345 while True:
346 if not child_busy:
347 self._busy_lock_inc()
348 child_busy = True
349 pop_failed = True
350 job = jobs_popleft()
351 pop_failed = False
352 if job is None or self._shutdown_children:
353 self._job_cnt.release()
354 run_child = False
355 break
356 fn, done_callback, args, kwargs = job
357 if done_callback is False:
358 if isgeneratorfunction(fn):
359 for _ in fn(*args, **kwargs):
360 pass
361 else:
362 fn(*args, **kwargs)
363 elif done_callback is True:
364 if isgeneratorfunction(fn):
365 jobid = id(job)
366 for result in fn(*args, **kwargs):
367 if self.result_id:
368 _done_append((jobid, result))
369 else:
370 _done_append(result)
371 self._done_cnt_inc()
372 else:
373 if self.result_id:
374 _done_append((id(job), fn(*args, **kwargs)))
375 else:
376 _done_append(fn(*args, **kwargs))
377 self._done_cnt_inc()
378 elif callable(done_callback):
379 if isgeneratorfunction(fn):
380 for result in fn(*args, **kwargs):
381 done_callback(result)
382 else:
383 done_callback(fn(*args, **kwargs))
384 except Exception as exc:
385 if self._shutdown_children:
386 self._job_cnt.release()
387 break
388 if pop_failed:
389 self._busy_lock_dec()

Callers

nothing calls this directly

Calls 7

_busy_lock_incMethod · 0.95
_done_cnt_incMethod · 0.95
_busy_lock_decMethod · 0.95
_append_failedMethod · 0.95
_cleanup_childMethod · 0.95
releaseMethod · 0.80
acquireMethod · 0.80

Tested by

no test coverage detected