asynchronous python call

J

joeygartin

Complete newbie, so forgive my improper use of Python terminology.

I am working with Django and I have to send off a number of emails
after a person has filled out a form. What I want is to make a call
that goes off to form and send the emails and redirect the user to
another view. I have this working now, but I noticed it is a bit
slow. So I was hoping there was a way to spin off the process and
redirect the user to the page while the emails are being formed and
sent vs. making the page hang while it is done.

Thank you!
 
T

Tino Wildenhain

Hi,
Complete newbie, so forgive my improper use of Python terminology.

I am working with Django and I have to send off a number of emails
after a person has filled out a form. What I want is to make a call
that goes off to form and send the emails and redirect the user to
another view. I have this working now, but I noticed it is a bit
slow. So I was hoping there was a way to spin off the process and
redirect the user to the page while the emails are being formed and
sent vs. making the page hang while it is done.

You best bet would be something like Zope's asynchronous mail handler
which is simply a queue Folder where you write the mail to be send
and having an outside process completely independend to scan for new
mail to be send out from time to time. If you want to speed up the
pickup time you could have the mail sender process open a socket (UDP
for example) where you can ping once you wrote out the mails to be send.

Regards
Tino
 
A

Aahz

I am working with Django and I have to send off a number of emails
after a person has filled out a form. What I want is to make a call
that goes off to form and send the emails and redirect the user to
another view. I have this working now, but I noticed it is a bit
slow. So I was hoping there was a way to spin off the process and
redirect the user to the page while the emails are being formed and
sent vs. making the page hang while it is done.

The simplest solution is to create an external program and use the
subprocess module to call it. You could also use fork() directly, but
that's more complicated.
--
Aahz ([email protected]) <*> http://www.pythoncraft.com/

"...string iteration isn't about treating strings as sequences of strings,
it's about treating strings as sequences of characters. The fact that
characters are also strings is the reason we have problems, but characters
are strings for other good reasons." --Aahz
 
L

Lawrence D'Oliveiro

The simplest solution is to create an external program and use the
subprocess module to call it.

You'll probably want to call os.setsid, so that the child process keeps
running after the parent terminates.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top