[Networkit] Catching SIGINT

Maximilian Vogel maximilian.vogel at student.kit.edu
Tue Jan 20 15:08:18 CET 2015


Fellow developers,

Under the branch sighandlingI 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
      o SignalHandling::init(caller): initialize this behaviour (with a
        root calling object)
      o SignalHandling::isRunning(): query, whether an algorithm can
        still run or not. It throws an InterruptException, if SIGINT has
        been captured.
      o 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20150120/d69e1e8f/attachment.html>


More information about the NetworKit mailing list