[Tutor] Is it a job for Thread or Process?

dman dsh8290@rit.edu
Thu, 15 Nov 2001 17:20:18 -0500


On Thu, Nov 15, 2001 at 05:02:23PM -0500, Andrei Kulakov wrote:
| On Thu, Nov 15, 2001 at 10:46:34PM +0100, A wrote:
| > Hello,
| > In my Python script I would like to start one function of this script 
| > in a different thread or process?
| > That function sends an email.
| > Can you please give me an example how I can start a new thread 
| > or process under Win32 systems?
| > 
| >  Is it better to  use a new thread  or a new process for this task?
| > Thank you for help.
| > Ladislav
| 
| Why use either? Sending a typical e-mail should take 1/10th of a second
| or less, I imagine..

It depends on the email subsystem and the network.  If you use unix
you can simply pipe to sendmail and forget about it.  With windows you
likely need to make the SMTP connection yourself, and the network and
size of the message has a huge effect.


Might your program need to exit before the email is finished sending?
What happens if the program crashes?  Does the email-sending component
need to report back to the main component?  

If you want the email to be send regardless of the state of the rest
of the system, I think an independent process is a good choice.  If
the email-seding component needs to communicate back with the other
components, then threads are easier to use for that.

HTH,
-D