[Networkit] Catching SIGINT

Christian Staudt christian.staudt at kit.edu
Tue Jan 20 15:32:06 CET 2015

Fellow developers,

this is one feature that has been on my wish list for a long time. I think Max has found a good solution. The changes to the code seem doable. The remaining question is what implications the polling of the flag has on performance. I’m awaiting some experimental data on that. If there’s no significant slowdown, I suggest that we implement this approach for all possibly long-running algorithms.

Request for feedback: Is there some drawback which we have not seen so far?


Am 20.01.2015 um 15:08 schrieb Maximilian Vogel <maximilian.vogel at student.kit.edu>:

> Fellow developers,
> Under the branch sighandling I pushed a prototype to catch CTRL+C/SIGINT signals which would be very convenient when working under the [I]Python Shell.
> The current approach looks as follows:
> A new class SignalHandling, that takes care of handling SIGINT, has been introduced. It also provides functions to
> SignalHandling::init(caller): initialize this behaviour (with a root calling object)
> SignalHandling::isRunning(): query, whether an algorithm can still run or not. It throws an InterruptException, if SIGINT has been captured.
> SignalHandling::reset(caller): reset the state of the class (booleans running and rootSet) in case root == caller.
> A new base class Algorithm, that provides a generic run()-method and takes care of the SignalHandling calls as well as the exception handling. 
> Are there any changes for developers?
> Yes. However, this approach has been chosen as it it seemed to be most convenient. Developers now need to implement their algorithms in the runImpl()-method, as the run()-method needs to be inherited from the generic Algorithm class. To enable the behaviour that an algorithm stops its execution when a SIGINT is received, it is sufficient to add a call to Aux::SignalHandling::isRunning() to conditions (maybe loop conditions) or at various checkpoints chosen by the programmer.
> Are there any changes for users?
> Nope, NetworKit can be used as before, but the [I]Python Shell won't crash anymore if you interrupt the algorithm with CTRL+C. :-)
> I encourage every NetworKit programmer to take a look at the code and to try it out. I'm open to your suggestions and general feedback. Please also report any bugs you encounter. Currently, it is implemented and works for PLM and PLP.
> Regards,
> Max
> <ATT00001.c>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20150120/d03c8295/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20150120/d03c8295/attachment.sig>

More information about the NetworKit mailing list