Skip to content

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

Description

@daniil-berg

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions