Skip to content

Webserver waits for task to finish in result() #113

@LourensVeen

Description

@LourensVeen

In the webserver (webserver/__init__.py), I noticed that result() waits for the corresponding Celery task to finish. What happens if you launch a long-running operation, and then request the result? That would block a server thread I think. Now what if you request it multiple times? Does that DOS the server?

I think it would be better to return a status message stating that the result is not yet available, and to try again in the future, instead of waiting. I had a look through the HTTP error codes, and 404 is the correct one to use here, as it means that the resource is unavailable at the moment (because it hasn't been calculated yet) but may become available in the future.

It should be possible for the user to distinguish between a 404 because the requested task does not exist, and a 404 because the result is not yet available. This could be done through a human-readable error message, or we could add a task status request that returns 404 if the task doesn't exist, but a "Processing" status if it does but isn't done yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions