i want to add a timeout to my code

maehhheeyy maehhheeyy at gmail.com
Tue Apr 29 17:47:40 EDT 2008


On Apr 17, 4:24 pm, Miki <miki.teb... at gmail.com> wrote:
> On Apr 17, 1:10 pm,maehhheeyy<maehhhe... at gmail.com> wrote:
>
> > I want to add a timeout so that when I pull out my gps from my serial
> > port, it would wait for a bit then loop and then see if it's there. I
> > also want to add a print statement saying that there is no GPS device
> > found. However when I run my code and unplug my serial port, my code
> > will just hang until I plug it back in.
> > This is my code right now:
>
> > def GetGPS():
> >       data = []
> >       #Open com1: 9600,8,N,1
> >       fi = serial.Serial(0, timeout = 1)
> >       print '[gps module] SERIAL PORT OPEN ON COM1:'
>
> > can anyone help me please? Thanks.
>
> http://docs.python.org/lib/node545.html
>
> HTH,
> --
> Miki <miki.teb... at gmail.com>http://pythonwise.blogspot.com

I tried the code onto my codes but what came out was that in the line
signal.signal(signal.SIGSLRM, handler), an attributeError appeared
reading that 'module' object has no attribute 'SIGALRM'



More information about the Python-list mailing list