def set_event_when_keyboard_interrupt(_lambda):
def wrapper(f):<EOL><INDENT>@wraps(f)<EOL>def wrapped_f(self, *f_args, **f_kwargs):<EOL><INDENT>try:<EOL><INDENT>f(self, *f_args, **f_kwargs)<EOL><DEDENT>except KeyboardInterrupt:<EOL><INDENT>_lambda(self).set()<EOL><INDENT>logging.info('<STR_LIT>' % _lambda(self).__name__)<EOL><DEDENT><DEDENT><DEDENT>return wrapped_f<EOL><DEDENT>return wrapper<EOL>
Decorator function that sets Threading.Event() when keyboard interrupt (Ctrl+C) was raised

    Parameters
    ----------
    _lambda : function
        Lambda function that points to Threading.Event() object

    Returns
    -------
    wrapper : function

    Examples
    --------
    @set_event_when_keyboard_interrupt(lambda x: x.stop_thread_event)
    def scan(self, **kwargs):
        # some code

    Note
    ----
    Decorated functions cannot be derived.