Skip to content

[gevent] Celery improper exit behavior on KeyboardInterrupt exception in task body. #457

Closed

Description

@linnik

Here is a sample:
http://pastebin.com/QnwT00G3
If i run task with sample.apply_async() and then hit Ctrl-C at console with worker - it's exit without exec any postrun signal and without sending result's state, return value, etc...
Gevent.sleep(value) doesn't make any sense, i think. That's all around KeyboardInterrupt. Usually, if you raise some exception during task execution, Celery will return 'Failed' state and will run signals, etc. But if we raise KeyboardInterrupt - we see this strange reaction. So it's all about wrong KeyboardInterrupt handling, i guess.
Here is a stacktrace: http://pastebin.com/YyHz2Mbq

Activity

  1. ask commented on Aug 27, 2011

    @ask
    Contributor

    Definitely about KeyboardInterrupt, but why doesn't gevent give control back to the green thread so the exception can be handled further down the stack, instead of raising it from the hubs stack?

  2. heyman commented on Sep 15, 2011

    @heyman
    Contributor

    Why does the pastebin output seem to suggest that there are multiple processes spawned, if it's running with the gevent pool?

    I don't know if this is the same, or related to, the issue I've been having when trying to hit CTRL-C or killing celery running on the gevent pool, but after the following changes I can now stop celery normally:

    heyman@85e678c

    My changes is a hack how ever, and I believe they break the ctrl-c/kill functionality when using the eventlet pool. Maybe one could just check what pool are used in the _stop handlers?

  3. heyman commented on Sep 19, 2011

    @heyman
    Contributor

    Upgrading to gevent 1.0a3 fixed the issue above. I now get a stacktrace when exiting celery in OSX, but it seems to work for me on Ubuntu/Linux. Maybe because epoll is used? I will conduct more testing.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions