Program mysteriously STOPS!

LJD ljd at nospam.com
Sat Jun 8 17:49:18 EDT 2002


Hi all:

The following code is designed (at least thats my intent) to run forever.  
The program should sit in a loop until it connects with the server.  It 
should just loop and loop and loop. 

It does, for a while, maybe five or ten minutes, but then the process just 
seems to vanish.  It's in the c1==0 loop when it quits. When I do a PS AUX, 
the process is just gone.  Obviously it quit, but more importantly WHY???, 
and what can I do so it doesn't?

Thanks,
Larry

------------------------------------------------------------------------------
(the code)

# Setup Parameters
HostIP = "192.168.0.3"
HostPort = 5020
HB_Interval = 1.0

############################################################################################################################

import socket
import time
import select

c1=0
c2=1

while c1 == 0:
        try:
                s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                s.connect(HostIP, HostPort)
                c1=1
                c2=1

        except socket.error,e:
                print e
                
                fe=open('/share/details.txt','a')
                t=time.time()
                fe.write(strftime('%H',t)
                fe.close()
                
                print time.time()
                time.sleep(5.0)
                c1=0
                c2=0

        while c2 == 1:
                EL=time.time()

                try:
                        r,w,e = select.select([s], [s], [s])
                        if w:
                                s.send(chr(32) + chr(5) + chr(0) + chr(8) +
 chr(0) + chr(0) + chr(0) + chr(0))

                        if r:
                                data=s.recv(50000)
                                tuple = time.localtime(time.time())
                                YR = time.strftime('%Y',tuple)
                                MO = time.strftime('%m',tuple)
                                DA = time.strftime('%d',tuple)
                                HR = time.strftime('%H',tuple)

                                f=open('/share/F' + YR + '_' + MO + '_' + D
A + '_' + HR + '_data.raw', 'ab')
                                f.write(data)
                                f.close()

                except socket.error,e:
                        print e
                        c2=0
                        c1=0
                        s.close()

                DL=time.time()
                TIL=DL-EL
                TR=HB_Interval-TIL
                if TR > 0:
                        time.sleep(TR)




More information about the Python-list mailing list