Say I need to send an email to myself when there is new comment.
and I don't want to block web.py presenting HTML to browser.
and Threading seems don't work here.
class comment:
def POST(self):
...
sender = Thread(target=_sendmail,args=('New Comment',msg))
sender.start()
referer = web.ctx.get('HTTP_REFERER', 'http://www.domain.com')
raise web.SeeOther(referer)
the problem when using threading is that once POST function is finished.. the sender within it would be freezed..usually sender didn't finish its job. And I certainly don't want to use sender.join() to wait for sender to end.
I think uwsgi don't have anything to do with this..
but I saw a explanation suggested that uwsgi suspended the web.py app.when there's no request.or request is done.
web.py provide an approach called @background.. http://webpy.org/cookbook/background
But it's seems have certain problems.it doesn't clean up threaddb dictionary.
and it would add an argument to the url like http://domain.com:8080/?_t=3080772748 which is ugly.
Is there an better solution? sending an email while serve url request as usual.