5 ms·
When building a small web app a few weeks ago, I tried to avoid additional dependencies, too. I was a bit stuck when I need to send an email asynchronous. Do yo
by bar-b-q 10y ago
When building a small web app a few weeks ago, I tried to avoid additional dependencies, too. I was a bit stuck when I need to send an email asynchronous. Do you have a _simple_ recommendation to solve this without pulling something huge like celery+redis in to solve this task?
- brianwawok 10y agoRQ + Reddis is "easier" http://python-rq.org/ http://python-rq.org/ If you are on AWS, you could just use something like their email service to fire off the request, then you don't need a queue at all.
- andybak 10y agoDepends on what you need. The bare minimum is to just spawn process so the request can return and your email can send. You tend to lack much control of failure conditions that way so you'd want to have some code in in the normal request/response cycle that checks for success or failure and informs the user. You could add your emails to a db table and have a cron job consume them. But for sending an occasional email? I've never really had a problem with just connecting to the SMTP server in the request/response cycle. If it takes more than a second to send then something is seriously wrong. You could use Mailgun or similar services which have their own queue for handling bulk sends and further reduce the likelihood of a problematic blocking of the web-server.
- bar-b-q 10y agoI'm in a corporate network where sending the email over our internal smtp takes about 5 seconds. I dont want the user to wait for this delay, so I'm using celery currently. It just felt a bit too much for such a little task. Maybe I will try something simpler like http://stackoverflow.com/a/4447147 http://stackoverflow.com/a/4447147