

def _setup_gevent_signals(self):
    if (self.gevent_signal_map is None):
        gevent.signal(signal.SIGTERM, self.terminate, signal.SIGTERM, None)
        return
    for (sig, target) in self.gevent_signal_map.items():
        if (target is None):
            raise ValueError('invalid handler argument for signal %s', str(sig))
        tocall = target
        args = [sig, None]
        if isinstance(target, list):
            if (not target):
                raise ValueError('handler list is empty for signal %s', str(sig))
            tocall = target[0]
            args = target[1:]
        elif isinstance(target, basestring):
            assert (not target.startswith('_'))
            tocall = getattr(self, target)
        gevent.signal(sig, tocall, *args)

dataset/ETHPy150Open gwik/geventdaemon/lib/geventdaemon.py GeventDaemonContext._setup_gevent_signals/original