File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 14
14
import webutil
15
15
import config
16
16
import time
17
+ import uwsgi
17
18
18
19
import logging
19
20
log = logging .getLogger ("bgtasks" )
@@ -25,11 +26,19 @@ def send_email(*args, **kwargs):
25
26
26
27
log .info ("send_email started, got arguments: {} {}" .format (args , kwargs ))
27
28
29
+ try :
30
+ log .info ("processing emails..." )
28
31
29
- log .info ("processing emails..." )
32
+ # do the stuff...
33
+ time .sleep (3 )
30
34
31
- # do the stuff...
32
- time .sleep (3 )
35
+ log .info ("processing done!" )
33
36
34
- log .info ("processing done!" )
37
+ except :
38
+ log .exception ("send_email" )
39
+
40
+ # returning SPOOL_OK here signals to uwsgi to not retry this task
41
+ # if the exception propagates up, uwsgi will call us again in
42
+ # N secs, configured in uwsgi.ini: spooler-frequency
43
+ return uwsgi .SPOOL_OK
35
44
You can’t perform that action at this time.
0 commit comments