"The compiled machine code does not include the regular polling done by Python, meaning that a KeyboardInterrupt will not be detected before execution comes back to the regular Python interpreter. Your program cannot be interrupted if caught into an infinite Psyco-compiled loop. (This could be fixed if requested.)"
I'm requesting it :)
I've just hit this problem with a debugging library I coded, WinAppDbg. My debugger's loop calls ctypes.windll.kernel32.WaitForDebugEvent in a loop. When the code is accelerated by psyco, I have no way of catching KeyboardInterrupt to know the user is trying to stop debugging.
My workaround was to include a call to time.sleep() of 0.2 seconds, but the value was found by trial-and-error and I fear it may vary from one machine to the next.
I'd be perfectly happy with having a way to tell psyco to manually poll for signals. Ideally one should be able to choose how often psyco accelerated code would check for asynchronous events, but a quick and dirty workaround is good enough for me.
For the time being I've isolated the calls to WaitForDebugEvent and similar APIs into separated functions and telling psyco not to compile them.
Log in to post a comment.