Talks

Writing Extension Modules To Be Interruptible

Saturday, May 17th, 2025 10:30 a.m.–11 a.m. in Room 301-305

Presented by

Zack Weinberg

Experience Level:

Advance experience

Description

Have you ever told Python to crunch some numbers, realized right after pressing RETURN that you made a mistake setting up the problem, hit control-C to stop it again...and then sat there twiddling your thumbs for a surprisingly long time as nothing seemed to happen?

The short version of what's going on when this happens is, the Python interpreter is notified of your having hit control-C almost immediately, but it has to wait to throw KeyboardInterrupt until the extension module that's doing the number crunching finishes its calculation and returns control to the interpreter.

In this talk we will discuss why the interpreter works that way (and why it has to work that way), what extension module authors can do today to make their extensions notice control-C promptly, and how we can all work toward a future where it's easy and natural for extension module authors to write extensions that don't make you wait for them to stop.

Search