How do I run routines where timing is critical?

S. David Rose photos at conversent.net
Mon Jun 21 04:06:30 CEST 2004


Hello All!
   I am new to Python, and wanted to know if I might ask you a question
regarding timing.  

  I want a main loop which takes photos from 8 different web-cams, each can
be addressed by http://ip-addr/image.jpg.  That's the easy part, but I want
to have 2 cameras poll 3-times a second, 4 cameras poll 2 times a second,
and the remaining 2 cameras poll once a second.  I have found lots of info
suggesting the use of threads for this, all using sleep to have a single
event fire every second or so.  But, what I'd like to do is have a loop
which does not need to 'sleep' but can rather evaluate where I am in the
second and then have that logic trigger the event. 

In otherwords,

While 1
  if second >1.00 and <1.25
     Camera 1 & camera 2
     Camera 5 & camera 6 & camera 7 & camera 8

  if second >1.25 and < 1.50
     Camera 1 & camera 2

  if second >1.50 and <1.75
     Camera 1 & camera 2
     Camera 5 & camera 6 & camera 7 & camera 8

  if second >1.75 and < 2.0
     Camera 1 & camera 2

  if second >1.00 and < 1.334
     Camera 3 & camera 4

  if second > 1.334 and < 1.667
     Camera 3 & camera 4

  if second > 1.667 and < 2.000
     Camera 3 & camera 4

Please don't be too harsh with me.  I'm still new, and am still quite
actively learning, but I've searched a bit on this and can't seem to find
it on my own.

Thank you in advance!
Dave Rose
Stamford, CT - USA



More information about the Python-list mailing list