File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,6 +94,10 @@ class PermanentTaskFailure(Error):
9494 """Indicates that a task failed, and will never succeed."""
9595
9696
97+ class SingularTaskFailure (Error ):
98+ """Indicates that a task failed once."""
99+
100+
97101class InvalidTaskError (Error ):
98102 """The parameters, headers, or method of the task is invalid."""
99103
Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ def abort(status):
4343
4444 try :
4545 deferred .run (data )
46+ except deferred .SingularTaskFailure :
47+ logger .debug ('Failure executing task, task retry forced' )
48+ return abort ('408 Request Timeout' )
4649 except deferred .PermanentTaskFailure :
4750 logger .exception ('Permanent failure attempting to execute task' )
4851 except Exception :
Original file line number Diff line number Diff line change 1010import pytest
1111from falcon import testing
1212
13+ from cloud_tasks_deferred import deferred
1314from cloud_tasks_deferred import wsgi
1415
1516
@@ -52,6 +53,16 @@ def test_application(simulate_post):
5253 assert response .status == falcon .HTTP_NO_CONTENT
5354
5455
56+ def test_application_singular_task_failure (simulate_post , mocker ):
57+ mocker .patch (
58+ 'cloud_tasks_deferred.deferred.run' ,
59+ side_effect = deferred .SingularTaskFailure ,
60+ )
61+ body = pickle .dumps ((bool , (), {}))
62+ response = simulate_post (body = body )
63+ assert response .status == '408 Request Timeout'
64+
65+
5566def test_application_permanent_task_failure (simulate_post ):
5667 body = pickle .dumps ('can not deserialize' )
5768 response = simulate_post (body = body )
You can’t perform that action at this time.
0 commit comments