How to schedule system calls with Python

Jorgen Grahn grahn+nntp at snipabacken.se
Thu Oct 22 00:01:05 CEST 2009


On Thu, 2009-10-15, TerryP wrote:
...
> launching external programs, irregardless of language, generally falls
> into 3 major categories:
>
>   0.) blocks until program is done; like system
>   1.) replaces your program with process, never returns; like exec
>   2.) quickly return after asynchronously launching the program
>
> Most languages will implement the first method because of the standard
> system() function in C, which is fairly popular in it's own right.
> Most multi-tasking operating systems will implement some form of exec
> function, which Python exposes through the os module. The last method
> is the least portable, because obviously if the OS lacks multi-tasking
> you're screwed. The best examples of 2. are the UNIX popen() function
> and Microsoft's spawn() family, when used with the P_DETACH flag.

Not sure that popen() fits nicely into that category -- you have to
eat the child's output or feed it with input, or it will eventually
stall.

> Python being made with much loving kindless, exposes each interface.

Nicely put!

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .  .
\X/     snipabacken.se>   O  o   .



More information about the Python-list mailing list