{"id":932,"hash":"ce44cf6604a3a555683c2db5cee82208e6cd89e53f9b02c16396dd78ec4c1a44","pattern":"Why does Celery NOT throw an Exception when the underlying task throws one","full_message":"Celery doesn't seem to be handling exceptions properly.  \n\nIf I have task:\n\ndef errorTest():\n    raise Exception()\n\nand then I call\n\nr = errorTest.delay()\nIn [8]: r.result\n\nIn [9]: r.state\nOut[9]: 'PENDING'\n\nAnd it will hang like this indefinitely.  \n\nGoing and checking the logs shows that the error IS getting thrown in the task (and if you want the message, ask), and I know that the backend and everything is set up properly because other tasks just work and return results correctly.  \n\nIs there something funky that I need to do to catch exceptions in Celery?\n\n/Celery version is 3.0.13, broker is RabbitMQ running on my local machine","ecosystem":"pypi","package_name":"exception","package_version":null,"solution":"You can define an on_failure function in your Task subclass to handle them correctly.  If you're just looking to find out what happened you can setup error email notifications that will send you the stack trace in your celery config.\n\nNote: As of v4 Celery no longer supports sending emails.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/14694771/why-does-celery-not-throw-an-exception-when-the-underlying-task-throws-one","votes":39,"created_at":"2026-04-19T04:52:02.701380+00:00","updated_at":"2026-04-19T04:52:02.701380+00:00"}