Thread imbalance

Tuvas tuvas21 at gmail.com
Mon Feb 6 12:52:22 EST 2006


The read function used actually is from a library in C, for use over a
CAN interface. The same library appears to work perfectly find over C.
I wrote an extention module for it. The function t_config is the
threaded function that will call a function called config once per
second. Note the time.time() timer

def t_config():
  while (TRUE):
    if(can_send_config):
      config()
      ts=time.time()
      time.sleep(1)
      if time.time()-ts>1.5:
        print "Long time detected
    else:
      time.sleep(.1)

When nothing is happening, the thread runs pretty consistantly at 1
second. However, when it is doing IO through this C function or
whatever, the length of time increases, for the time.sleep() function.
Kind of strange, isn't it? I can explain in more detail if it's needed,
but I don't know how much it'll help...




More information about the Python-list mailing list