KeyboardInterrupt vs extension written in C

Tamas Nepusz ntamas at gmail.com
Thu Oct 20 18:39:54 EDT 2005


No, that's actually a bit more complicated. The library I'm working on
is designed for performing calculations on large-scale graphs (~10000
nodes and edges). I want to create a Python interface for that library,
so what I want to accomplish is that I could just type "from igraph
import *" in a Python command line and then access all of the
functionalities of the igraph library. Now it works, except the fact
that if, for example, I start computing the diameter of a random graph
of ~100000 nodes and ~200000 edges, I can't cancel it, because the
KeyboardInterrupt is not propagated to the Python toplevel (or it isn't
even generated until the igraph library routine returns). I would like
to allow the user to cancel the computation with the usual Ctrl-C and
return to the Python interactive interface.
This whole feature is not vital, but it would mean a big step towards
user-friendliness.
I have access to the source code of igraph as well (since one of my
colleagues is developing it), so another possible solution would be to
inject some calls into the igraph source code which temporarily cancels
the computation and checks whether there's something waiting in the
Python interpreter, but I haven't found any function in the API which
allows me to do this.

Tamas




More information about the Python-list mailing list