By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,089 Members | 2,418 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,089 IT Pros & Developers. It's quick & easy.

KeyboardInterrupt from syscalls

P: n/a
Dear List,

I was writing a Python extension module, including a sleeping call to
poll(2), and noticed, to my great surprise (and joy), that even when
blocking there, KeyboardInterrupt still worked properly when sending
SIGINTs to the interpreter. It really got me wondering how it works,

I would have thought that I would have to check manually for interrupts
in one way or another, seeing how the thread in question should be stuck
in my syscall. Sure, I return on EINTR, but I only return Py_FALSE, not
NULL, so I wouldn't have thought that the interpreter would look for an
exception having taken place (I would assume that it gets set in the

So how does it work? Does my code get to return Py_FALSE, and the
interpreter ignores it, seeing that an exception is set? Is a non-local
exit performed right over my call stack (in which case my next question
would be how to clean up resources being used from my C code)? Or does
something completely else happen?

Fredrik Tolf
Nov 22 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.