Both the TaskPool._apply_spawner and the SimpleTaskPool._start_num methods continue to loop, if an exception is raised during the creation of the target coroutine, but before it is scheduled for execution.
|
for i in range(num): |
|
try: |
|
coroutine = func(*args, **kwargs) |
|
except Exception as e: |
|
# Probably something wrong with the function arguments. |
|
log.exception( |
|
"%s occurred in group '%s' while trying to " |
|
"create coroutine: %s(*%s, **%s)", |
|
str(e.__class__.__name__), |
|
group_name, |
|
func.__name__, |
|
repr(args), |
|
repr(kwargs), |
|
) |
|
continue # TODO: Consider returning instead of continuing |
This is likely only something that can happen, if the function arguments are wrong or the target is not callable at all. In that case continuing to loop seems unnecessary and wasteful. Returning immediately or even re-raising the exception seems more appropriate.
Both the
TaskPool._apply_spawnerand theSimpleTaskPool._start_nummethods continue to loop, if an exception is raised during the creation of the target coroutine, but before it is scheduled for execution.asyncio-taskpool/src/asyncio_taskpool/pool.py
Lines 788 to 802 in 27eb3bf
This is likely only something that can happen, if the function arguments are wrong or the target is not callable at all. In that case continuing to loop seems unnecessary and wasteful. Returning immediately or even re-raising the exception seems more appropriate.