#80 Request to fix the KeyboardInterrupt problem (known bug #2)

Mario Vilas

"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.


  • Mario Vilas

    Mario Vilas - 2009-05-19

    Uhm, then again, I just read at another ticket that psyco is in "maintenance only" mode, so that probably means it's not going to get fixed. I guess I'll stick to using psyco.cannotcompile(), then.

  • Christian Tismer

    Will try treat this as part of the compiler strategy change using total recall.
    I think to add the periodic checks, ignoring the speed penalty more or less.

  • Christian Tismer

    • assigned_to: nobody --> tismer
    • status: open --> open-remind
  • Christian Tismer

    • status: open-remind --> open
  • Christian Tismer

    Psyco is no longer in maintenance only mode, but resurrected to active development


Log in to post a comment.