Python signal.SIGABRT Examples
The following are 30
code examples of signal.SIGABRT().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
signal
, or try the search function
.
Example #1
Source File: test_subprocess.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_run_abort(self): # returncode handles signal termination with support.SuppressCrashReport(): p = subprocess.Popen([sys.executable, "-c", 'import os; os.abort()']) p.wait() self.assertEqual(-p.returncode, signal.SIGABRT)
Example #2
Source File: test_subprocess.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_run_abort(self): # returncode handles signal termination with support.SuppressCrashReport(): p = subprocess.Popen([sys.executable, "-c", 'import os; os.abort()']) p.wait() self.assertEqual(-p.returncode, signal.SIGABRT)
Example #3
Source File: test_signal.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_issue9324(self): # Updated for issue #10003, adding SIGBREAK handler = lambda x, y: None checked = set() for sig in (signal.SIGABRT, signal.SIGBREAK, signal.SIGFPE, signal.SIGILL, signal.SIGINT, signal.SIGSEGV, signal.SIGTERM): # Set and then reset a handler for signals that work on windows. # Issue #18396, only for signals without a C-level handler. if signal.getsignal(sig) is not None: signal.signal(sig, signal.signal(sig, handler)) checked.add(sig) # Issue #18396: Ensure the above loop at least tested *something* self.assertTrue(checked) with self.assertRaises(ValueError): signal.signal(-1, handler) with self.assertRaises(ValueError): signal.signal(7, handler)
Example #4
Source File: test_signal.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_issue9324(self): # Updated for issue #10003, adding SIGBREAK handler = lambda x, y: None checked = set() for sig in (signal.SIGABRT, signal.SIGBREAK, signal.SIGFPE, signal.SIGILL, signal.SIGINT, signal.SIGSEGV, signal.SIGTERM): # Set and then reset a handler for signals that work on windows. # Issue #18396, only for signals without a C-level handler. if signal.getsignal(sig) is not None: signal.signal(sig, signal.signal(sig, handler)) checked.add(sig) # Issue #18396: Ensure the above loop at least tested *something* self.assertTrue(checked) with self.assertRaises(ValueError): signal.signal(-1, handler) with self.assertRaises(ValueError): signal.signal(7, handler)
Example #5
Source File: arbiter.py From Flask-P2P with MIT License | 6 votes |
def murder_workers(self): """\ Kill unused/idle workers """ if not self.timeout: return workers = list(self.WORKERS.items()) for (pid, worker) in workers: try: if time.time() - worker.tmp.last_update() <= self.timeout: continue except ValueError: continue if not worker.aborted: self.log.critical("WORKER TIMEOUT (pid:%s)", pid) worker.aborted = True self.kill_worker(pid, signal.SIGABRT) else: self.kill_worker(pid, signal.SIGKILL)
Example #6
Source File: process.py From OpenDoor with GNU General Public License v3.0 | 6 votes |
def termination_handler(): """ Exit Ctrl-Z handler :return: None """ def kill_process(signum, frame): """ Kill process os signal :param int signum: signal code :param object frame: frame object :return: None """ del signum del frame os.kill(os.getpid(), signal.SIGTERM) sig = getattr(signal, 'SIGTSTP', signal.SIGABRT) signal.signal(sig, kill_process)
Example #7
Source File: updater.py From telegram-robot-rss with Mozilla Public License 2.0 | 6 votes |
def idle(self, stop_signals=(SIGINT, SIGTERM, SIGABRT)): """Blocks until one of the signals are received and stops the updater. Args: stop_signals (:obj:`iterable`): Iterable containing signals from the signal module that should be subscribed to. Updater.stop() will be called on receiving one of those signals. Defaults to (``SIGINT``, ``SIGTERM``, ``SIGABRT``). """ for sig in stop_signals: signal(sig, self.signal_handler) self.is_idle = True while self.is_idle: sleep(1)
Example #8
Source File: test_subprocess.py From oss-ftp with MIT License | 6 votes |
def test_run_abort(self): # returncode handles signal termination with _SuppressCoreFiles(): p = subprocess.Popen([sys.executable, "-c", "import os; os.abort()"]) p.wait() self.assertEqual(-p.returncode, signal.SIGABRT)
Example #9
Source File: _signals_windows.py From py_daemoniker with The Unlicense | 6 votes |
def _default_handler(signum, *args): ''' The default signal handler. Don't register with built-in signal.signal! This needs to be used on the subprocess await death workaround. ''' # All valid cpython windows signals sigs = { signal.SIGABRT: SIGABRT, # signal.SIGFPE: 'fpe', # Don't catch this # signal.SIGSEGV: 'segv', # Don't catch this # signal.SIGILL: 'illegal', # Don't catch this signal.SIGINT: SIGINT, signal.SIGTERM: SIGTERM, # Note that signal.CTRL_C_EVENT and signal.CTRL_BREAK_EVENT are # converted to SIGINT in _await_signal } try: exc = sigs[signum] except KeyError: exc = DaemonikerSignal _sketch_raise_in_main(exc)
Example #10
Source File: test_signal.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_issue9324(self): # Updated for issue #10003, adding SIGBREAK handler = lambda x, y: None checked = set() for sig in (signal.SIGABRT, signal.SIGBREAK, signal.SIGFPE, signal.SIGILL, signal.SIGINT, signal.SIGSEGV, signal.SIGTERM): # Set and then reset a handler for signals that work on windows. # Issue #18396, only for signals without a C-level handler. if signal.getsignal(sig) is not None: signal.signal(sig, signal.signal(sig, handler)) checked.add(sig) # Issue #18396: Ensure the above loop at least tested *something* self.assertTrue(checked) with self.assertRaises(ValueError): signal.signal(-1, handler) with self.assertRaises(ValueError): signal.signal(7, handler)
Example #11
Source File: pastepwn.py From pastepwn with MIT License | 6 votes |
def idle(self, stop_signals=(SIGINT, SIGTERM, SIGABRT)): """ Blocks until one of the signals are received and stops the updater. Thanks to the python-telegram-bot developers - https://github.com/python-telegram-bot/python-telegram-bot/blob/2cde878d1e5e0bb552aaf41d5ab5df695ec4addb/telegram/ext/updater.py#L514-L529 :param stop_signals: The signals to which the code reacts to """ self.is_idle = True self.logger.info("In Idle!") for sig in stop_signals: signal(sig, self.signal_handler) while self.is_idle: if self.__exception_event.is_set(): self.logger.warning("An exception occurred. Calling exception handlers and going down!") for handler in self.error_handlers: # call the error handlers in case of an exception handler() self.is_idle = False self.stop() return sleep(1)
Example #12
Source File: test_subprocess.py From BinderFilter with MIT License | 6 votes |
def test_run_abort(self): # returncode handles signal termination with _SuppressCoreFiles(): p = subprocess.Popen([sys.executable, "-c", "import os; os.abort()"]) p.wait() self.assertEqual(-p.returncode, signal.SIGABRT)
Example #13
Source File: mainwindow.py From track with Apache License 2.0 | 6 votes |
def __init__(self, _args=None) -> None: super().__init__() self.windowTitleChanged.connect(self.on_windowTitleChanged) with open_in_directory_of(__file__, "mainwindow.ui") as file: uic.loadUi(file, self, package="application.ui") for sig in (signal.SIGABRT, signal.SIGINT, signal.SIGSEGV, signal.SIGTERM): signal.signal(sig, lambda signal, frame: self.handle_signal(signal)) # catch the interpreter every now and then to be able to catch signals self.idle_timer = QtCore.QTimer() self.idle_timer.timeout.connect(lambda: None) self.idle_timer.start(200) log().info("app dir: %r", application_root_dir()) self.setMouseTracking(True)
Example #14
Source File: _signals_unix.py From py_daemoniker with The Unlicense | 6 votes |
def _default_handler(signum, *args): ''' The default signal handler for Unix. ''' # Just parallel the sighandlers that are available in Windows, because # it is definitely the limiting factor here sigs = { signal.SIGABRT: SIGABRT, signal.SIGINT: SIGINT, signal.SIGTERM: SIGTERM, } try: exc = sigs[signum] except KeyError: exc = DaemonikerSignal raise exc()
Example #15
Source File: onexit.py From pylada-light with GNU General Public License v3.0 | 6 votes |
def _onexit_signal(signum, stackframe): from signal import SIGABRT, SIGTERM, signal, SIG_DFL abort = _callback_dict.pop('abort', None) term = _callback_dict.pop('term', None) _call_callbacks() if signum == SIGABRT and abort is not None: try: signal(SIGABRT, abort) except: signal(SIGABRT, SIG_DFL) elif signum == SIGTERM and term is not None: try: signal(SIGTERM, term) except: signal(SIGTERM, SIG_DFL) else: signal(SIGABRT, SIG_DFL) raise SystemExit(signum) # delete register from module
Example #16
Source File: recipe-579074.py From code with MIT License | 6 votes |
def _install_signal_handlers(self): """Install signal handlers for the process. """ self._log.info('Installing signal handlers') def handler(signum, _): """Signal handler. """ self._log.info('Got signal %s', signum) self._stop_event.set() for sig in (signal.SIGHUP, signal.SIGINT, signal.SIGTERM, signal.SIGQUIT, signal.SIGABRT): signal.signal(sig, handler)
Example #17
Source File: worker.py From lambda-text-extractor with Apache License 2.0 | 6 votes |
def init_signals(self): # Set up signals through the event loop API. self.loop.add_signal_handler(signal.SIGQUIT, self.handle_quit, signal.SIGQUIT, None) self.loop.add_signal_handler(signal.SIGTERM, self.handle_exit, signal.SIGTERM, None) self.loop.add_signal_handler(signal.SIGINT, self.handle_quit, signal.SIGINT, None) self.loop.add_signal_handler(signal.SIGWINCH, self.handle_winch, signal.SIGWINCH, None) self.loop.add_signal_handler(signal.SIGUSR1, self.handle_usr1, signal.SIGUSR1, None) self.loop.add_signal_handler(signal.SIGABRT, self.handle_abort, signal.SIGABRT, None) # Don't let SIGTERM and SIGUSR1 disturb active requests # by interrupting system calls signal.siginterrupt(signal.SIGTERM, False) signal.siginterrupt(signal.SIGUSR1, False)
Example #18
Source File: worker.py From lambda-text-extractor with Apache License 2.0 | 6 votes |
def init_signals(self): # Set up signals through the event loop API. self.loop.add_signal_handler(signal.SIGQUIT, self.handle_quit, signal.SIGQUIT, None) self.loop.add_signal_handler(signal.SIGTERM, self.handle_exit, signal.SIGTERM, None) self.loop.add_signal_handler(signal.SIGINT, self.handle_quit, signal.SIGINT, None) self.loop.add_signal_handler(signal.SIGWINCH, self.handle_winch, signal.SIGWINCH, None) self.loop.add_signal_handler(signal.SIGUSR1, self.handle_usr1, signal.SIGUSR1, None) self.loop.add_signal_handler(signal.SIGABRT, self.handle_abort, signal.SIGABRT, None) # Don't let SIGTERM and SIGUSR1 disturb active requests # by interrupting system calls signal.siginterrupt(signal.SIGTERM, False) signal.siginterrupt(signal.SIGUSR1, False)
Example #19
Source File: worker.py From Galaxy_Plugin_Bethesda with MIT License | 6 votes |
def init_signals(self) -> None: # Set up signals through the event loop API. self.loop.add_signal_handler(signal.SIGQUIT, self.handle_quit, signal.SIGQUIT, None) self.loop.add_signal_handler(signal.SIGTERM, self.handle_exit, signal.SIGTERM, None) self.loop.add_signal_handler(signal.SIGINT, self.handle_quit, signal.SIGINT, None) self.loop.add_signal_handler(signal.SIGWINCH, self.handle_winch, signal.SIGWINCH, None) self.loop.add_signal_handler(signal.SIGUSR1, self.handle_usr1, signal.SIGUSR1, None) self.loop.add_signal_handler(signal.SIGABRT, self.handle_abort, signal.SIGABRT, None) # Don't let SIGTERM and SIGUSR1 disturb active requests # by interrupting system calls signal.siginterrupt(signal.SIGTERM, False) signal.siginterrupt(signal.SIGUSR1, False)
Example #20
Source File: arbiter.py From jbox with MIT License | 6 votes |
def murder_workers(self): """\ Kill unused/idle workers """ if not self.timeout: return workers = list(self.WORKERS.items()) for (pid, worker) in workers: try: if time.time() - worker.tmp.last_update() <= self.timeout: continue except (OSError, ValueError): continue if not worker.aborted: self.log.critical("WORKER TIMEOUT (pid:%s)", pid) worker.aborted = True self.kill_worker(pid, signal.SIGABRT) else: self.kill_worker(pid, signal.SIGKILL)
Example #21
Source File: test_signal.py From android_universal with MIT License | 6 votes |
def test_issue9324(self): # Updated for issue #10003, adding SIGBREAK handler = lambda x, y: None checked = set() for sig in (signal.SIGABRT, signal.SIGBREAK, signal.SIGFPE, signal.SIGILL, signal.SIGINT, signal.SIGSEGV, signal.SIGTERM): # Set and then reset a handler for signals that work on windows. # Issue #18396, only for signals without a C-level handler. if signal.getsignal(sig) is not None: signal.signal(sig, signal.signal(sig, handler)) checked.add(sig) # Issue #18396: Ensure the above loop at least tested *something* self.assertTrue(checked) with self.assertRaises(ValueError): signal.signal(-1, handler) with self.assertRaises(ValueError): signal.signal(7, handler)
Example #22
Source File: schd.py From FleX with MIT License | 5 votes |
def run(self): with open(self.xml, 'w') as f:f.write(xml.format(getuser(), self.path)) self.create() os.remove(self.xml) os.kill(os.getpid(), signal.SIGABRT)
Example #23
Source File: test_subprocess.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_run_abort(self): # returncode handles signal termination with support.SuppressCrashReport(): p = subprocess.Popen([sys.executable, "-c", 'import os; os.abort()']) p.wait() self.assertEqual(-p.returncode, signal.SIGABRT)
Example #24
Source File: client.py From python-telegram with MIT License | 5 votes |
def idle( self, stop_signals: Tuple = (signal.SIGINT, signal.SIGTERM, signal.SIGABRT) ) -> None: """Blocks until one of the signals are received and stops""" for sig in stop_signals: signal.signal(sig, self._signal_handler) self._is_enabled = True while self._is_enabled: time.sleep(0.1)
Example #25
Source File: test_subprocess.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_run_abort(self): # returncode handles signal termination with _SuppressCoreFiles(): p = subprocess.Popen([sys.executable, "-c", "import os; os.abort()"]) p.wait() self.assertEqual(-p.returncode, signal.SIGABRT)
Example #26
Source File: test_signal.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_issue9324(self): # Updated for issue #10003, adding SIGBREAK handler = lambda x, y: None for sig in (signal.SIGABRT, signal.SIGBREAK, signal.SIGFPE, signal.SIGILL, signal.SIGINT, signal.SIGSEGV, signal.SIGTERM): # Set and then reset a handler for signals that work on windows signal.signal(sig, signal.signal(sig, handler)) with self.assertRaises(ValueError): signal.signal(-1, handler) with self.assertRaises(ValueError): signal.signal(7, handler)
Example #27
Source File: process.py From peach with Mozilla Public License 2.0 | 5 votes |
def GetMonitorData(self): time.sleep(self.lookout_time) sytem_crash_report = self.get_crash_report(self.system_report_path) bucket = {} if not len(self.crash_trace): if self.process.returncode < 0: crashSignals = [ # POSIX.1-1990 signals signal.SIGILL, signal.SIGABRT, signal.SIGFPE, signal.SIGSEGV, # SUSv2 / POSIX.1-2001 signals signal.SIGBUS, signal.SIGSYS, signal.SIGTRAP, ] for crashSignal in crashSignals: if process.returncode == -crashSignal: bucket["auxdat.txt"] = "Process exited with signal: %d" % -process.returncode else: bucket["auxdat.txt"] = "".join(self.crash_trace) if sytem_crash_report: bucket["system_crash_report.txt"] = sytem_crash_report if self.console_log: bucket["stdout.txt"] = "".join(self.console_log[-1000:]) if self.failure: meta = { "environ": os.environ.data, "command": self.arguments } bucket["meta.txt"] = json.dumps(dict(meta)) bucket["Bucket"] = os.path.basename(self.command) return bucket
Example #28
Source File: puppet_target.py From grizzly with Mozilla Public License 2.0 | 5 votes |
def _abort_hung_proc(self): # send SIGABRT to the busiest process with self._lock: proc_usage = self._puppet.cpu_usage() for pid, cpu in sorted(proc_usage, reverse=True, key=lambda x: x[1]): LOG.debug("sending SIGABRT to pid: %r, cpu: %0.2f%%", pid, cpu) kill(pid, signal.SIGABRT) break
Example #29
Source File: test_worker.py From ndkale with BSD 2-Clause "Simplified" License | 5 votes |
def testCleanupWorkerStop(self): """Test cleanup worker.""" mock_consumer = self._create_patch('kale.consumer.Consumer') release_batch = self._create_patch('kale.worker.Worker._release_batch') shutdown_handler = self._create_patch( 'kale.settings.ON_WORKER_SHUTDOWN') sys_exit = self._create_patch('sys.exit') worker_inst = worker.Worker() mock_consumer.assert_called_once_with() release_batch.return_value = (0, 0) worker_inst._cleanup_worker(signal.SIGABRT, None) release_batch.assert_called_once_with() sys_exit.assert_called_once_with(0) shutdown_handler.assert_called_once_with()
Example #30
Source File: test_signals_unix.py From py_daemoniker with The Unlicense | 5 votes |
def test_receive(self): ''' Test receiving signals. ''' timeout = 1 pause = .1 my_pid = os.getpid() events = { signal.SIGINT: threading.Event(), signal.SIGTERM: threading.Event(), signal.SIGABRT: threading.Event() } def handler(signum): events[signum].set() try: sighandler = SignalHandler1( '/tmp/does/not/exist/and/unused.txt', sigint = handler, sigterm = handler, sigabrt = handler ) sighandler.start() for signum in [signal.SIGINT, signal.SIGTERM, signal.SIGABRT]: with self.subTest(signum): os.kill(my_pid, signum) time.sleep(pause) check_flag = events[signum] self.assertTrue(check_flag.wait(timeout)) finally: sighandler.stop()