[Tutor] continuouse loop

Martin Walsh mwalsh at groktech.org
Fri Jul 18 03:15:54 CEST 2008


Monika Jisswel wrote:
> Would a program using a continuouse loop such as in this code take up
> resources on the system if left for long period ?
> 
>     import sys
> 
>     while 1:
>         self.data = sys.stdin.readline()
>         self.function_1(data)

Not much, I would think, until something is written to stdin of this
program, and then it would depend on what function_1 does.

> What are my other options is I want to have a running program & other
> programs communicate with it & get responses from it ?

If I understand what you're asking, there are a few options outlined in
the python library reference, here:
http://docs.python.org/lib/ipc.html

I would add named pipes as another option for *nix, windows may have
something similar. And, depending on what you're trying to accomplish
maybe xmlrpclib, soappy, pyro, or perhaps even cgi.

HTH,
Marty



More information about the Tutor mailing list