Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop applying/starting, if an error occurs during coroutine creation #5

Open
daniil-berg opened this issue Oct 14, 2023 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@daniil-berg
Copy link
Owner

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.

@daniil-berg daniil-berg added invalid This doesn't seem right enhancement New feature or request and removed invalid This doesn't seem right labels Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant