How to use _handle_signal method in pyatom

Best Python code snippet using pyatom_python

service.py

Source:service.py Github

copy

Full Screen

...70 def __init__(self, signo, exccode=1):71 super(SignalExit, self).__init__(exccode)72 self.signo = signo73class ServiceLauncher(Launcher):74 def _handle_signal(self, signo, frame):75 # Allow the process to be killed again and die from natural causes76 signal.signal(signal.SIGTERM, signal.SIG_DFL)77 signal.signal(signal.SIGINT, signal.SIG_DFL)78 raise SignalExit(signo)79 def wait(self):80 signal.signal(signal.SIGTERM, self._handle_signal)81 signal.signal(signal.SIGINT, self._handle_signal)82 LOG.debug(_('Full set of CONF:'))83 CONF.log_opt_values(LOG, std_logging.DEBUG)84 status = None85 try:86 super(ServiceLauncher, self).wait()87 except SignalExit as exc:88 signame = {signal.SIGTERM: 'SIGTERM',89 signal.SIGINT: 'SIGINT'}[exc.signo]90 LOG.info(_('Caught %s, exiting'), signame)91 status = exc.code92 except SystemExit as exc:93 status = exc.code94 finally:95 if rpc:96 rpc.cleanup()97 self.stop()98 return status99class ServiceWrapper(object):100 def __init__(self, service, workers):101 self.service = service102 self.workers = workers103 self.children = set()104 self.forktimes = []105class ProcessLauncher(object):106 def __init__(self):107 self.children = {}108 self.sigcaught = None109 self.running = True110 rfd, self.writepipe = os.pipe()111 self.readpipe = eventlet.greenio.GreenPipe(rfd, 'r')112 signal.signal(signal.SIGTERM, self._handle_signal)113 signal.signal(signal.SIGINT, self._handle_signal)114 def _handle_signal(self, signo, frame):115 self.sigcaught = signo116 self.running = False117 # Allow the process to be killed again and die from natural causes118 signal.signal(signal.SIGTERM, signal.SIG_DFL)119 signal.signal(signal.SIGINT, signal.SIG_DFL)120 def _pipe_watcher(self):121 # This will block until the write end is closed when the parent122 # dies unexpectedly123 self.readpipe.read()124 LOG.info(_('Parent process has died unexpectedly, exiting'))125 sys.exit(1)126 def _child_process(self, service):127 # Setup child signal handlers differently128 def _sigterm(*args):...

Full Screen

Full Screen

multiprocess_test.py

Source:multiprocess_test.py Github

copy

Full Screen

...19 self.signal_event = threading.Event()20 signal.signal(signal.SIGINT, self._handle_signal)21 signal.signal(signal.SIGTSTP, self._handle_signal)22 signal.signal(signal.SIGTERM, self._handle_signal)23 def _handle_signal(self, signalnum, frame):24 self.signal_event.set()25a = 'rohan'26print(a, id(a))27def worker(queue, i):28 shutdown_handler = ShutdownHandler()29 a = i30 print(a, id(a))31 while not shutdown_handler.signal_event.is_set():32 try:33 msg = queue.get(True, 1)34 except:35 msg = None36 if msg:37 print(msg)...

Full Screen

Full Screen

_app.py

Source:_app.py Github

copy

Full Screen

...31 """32 Return True if the application registered signals handlers.33 """34 return _registered_signals35def _handle_signal(signo, frame):36 global _termination_signal37 if _termination_signal is None:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyatom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful