Skip to content

Commit 1d110fb

Browse files
committed
bgtask returns SPOOL_OK
1 parent 545f19b commit 1d110fb

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

py/bgtasks.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import webutil
1515
import config
1616
import time
17+
import uwsgi
1718

1819
import logging
1920
log = logging.getLogger("bgtasks")
@@ -25,11 +26,19 @@ def send_email(*args, **kwargs):
2526

2627
log.info("send_email started, got arguments: {} {}".format(args, kwargs))
2728

29+
try:
30+
log.info("processing emails...")
2831

29-
log.info("processing emails...")
32+
# do the stuff...
33+
time.sleep(3)
3034

31-
# do the stuff...
32-
time.sleep(3)
35+
log.info("processing done!")
3336

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
3544

0 commit comments

Comments
 (0)