Thanks Daniel, that's interesting. Unfortunately there is no sensible code I can post because this only happens when I make a specific call into the vendors SDK. I can exercise my own code in the extension without a problem. The python test calling code is doing practically nothing. I make 3 calls to the extension to set things going and then loop every 5 seconds and print the time. I know Pythons own threading model is cooperative because of the GIL and therefore one thread can hog the show but I've never had issues with threads running in a C extension messing up a Python thread. I really need to understand what mechanism is at play here rather than work around it.
Bob The time.clock() function does increment correctly. CPU is around 30% On 05/05/2012 21:17, Danyel Lawson wrote: > Add a time.sleep(0) call to all your loops. Multithreading in Python > is a cooperative cross platform threading simulation if you have tight > loops Python won't task switch until you make a system call. > Potentially preventing internal library variables from being updated. > > Your five minute interval may be almost exactly how long it takes to > process a flooded queue in a tight loop in your program and it may be > why it continues to happen as the queue waits to fill again while > processing happens. > > You can simulate the progression of time by overriding the time.time > function by simply setting it to a function that just increments a > module level or function property variable. You can also override the > time.time function to return the posix time function's value to maybe > get around whatever optimization is happening in the time.time > function to pass back the same value. > > If you post your sample code that exhibits the same behavior it may be > obvious to someone on the list as to what is the problem. > > > > On Sat, May 5, 2012 at 3:33 PM, Bob Cowdery <b...@bobcowdery.plus.com> wrote: >> Hi all, >> >> I've been a long time user of Python and written many extensions but >> this problem has me stumped. >> >> I've written a straight forward extension that wraps a vendors SDK for a >> video capture card. All works well except that in the Python thread on >> which I call the extension, after certain calls that I believe are using >> DirectShow, time stands still. The thread returns fine as the extension >> does its stuff in its own threads. In all other respects the Python >> thread seems unaffected but calls to time.time() always return the same >> time which is usually several seconds in the past or future and always >> has no fractional part. If I leave it long enough time will suddently >> jump forward after a few minutes, then again after a few minutes more. >> >> I've never encountered this behaviour before and can't understand what >> on earth is going on. If I call the 'C' time() function just the other >> side of my call to the extension the time is ticking along fine. It's >> just the one Python thread that is affected. If I call from the main >> thread then the main thread is affected. The calling program I've used >> to test this is just a few lines long. >> >> I believe the time function is a thin wrapper over the 'C' runtime so >> its very odd that time only stands still on the Python side but not on >> the 'C' side. As time is built in I've not looked at the code as its not >> in the distribution. Don't know if it would help to do that. >> >> This also can affect the time.sleep() function making it return >> immediately but that only seems to happen in my full application. >> >> Any ideas would be very greatly received. >> >> Bob >> -- >> http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list