Control over Communication Processes

Niels Diepeveen niels at endea.demon.nl
Sat May 20 13:40:52 EDT 2000


Benny Shomer schreef:

> 2. Fork a child process, which can safely be killed in the even of
> stalled connections.
>        BUT:  The child, although it receives the self environment, can
>              only read it, but can't modify it. So:
>              a. It can't directly send the data back to the spawning
>                 class (this is solvable through using a temp file, or
>                 less likely a pipe, because the pipe will stall together
>                 with the connection)
Could use select(), but probably not worth it.

>              b. It has no effective way of resetting the class timer
>                 so the clock will be ticking even if the child works
>                 but simply reads large amounts of data (which is my
>                 case), so it gets killed when it's not supposed to...

If you do something like:
    while 1:
        signal.alarm(60)
        Read some data
        if no more data:
            break
        Save data
    signal.alarm(0)
in the child process, it will be killed if it doesn't receive any data
for 60 seconds. From the return code of os.wait() in the parent you can
tell whether it terminated normally or timed out. Is that what you want?

-- 
Niels Diepeveen
Endea automatisering




More information about the Python-list mailing list