diff options
-rw-r--r-- | Doc/library/faulthandler.rst | 8 | ||||
-rw-r--r-- | Lib/test/test_faulthandler.py | 38 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/faulthandler.c | 28 |
4 files changed, 40 insertions, 37 deletions
diff --git a/Doc/library/faulthandler.rst b/Doc/library/faulthandler.rst index b079b30..3c33621 100644 --- a/Doc/library/faulthandler.rst +++ b/Doc/library/faulthandler.rst @@ -71,7 +71,7 @@ Fault handler state Dump the tracebacks after a timeout ----------------------------------- -.. function:: dump_tracebacks_later(timeout, repeat=False, file=sys.stderr, exit=False) +.. function:: dump_traceback_later(timeout, repeat=False, file=sys.stderr, exit=False) Dump the tracebacks of all threads, after a timeout of *timeout* seconds, or every *timeout* seconds if *repeat* is ``True``. If *exit* is ``True``, call @@ -84,9 +84,9 @@ Dump the tracebacks after a timeout This function is implemented using a watchdog thread and therefore is not available if Python is compiled with threads disabled. -.. function:: cancel_dump_tracebacks_later() +.. function:: cancel_dump_traceback_later() - Cancel the last call to :func:`dump_tracebacks_later`. + Cancel the last call to :func:`dump_traceback_later`. Dump the traceback on a user signal @@ -112,7 +112,7 @@ Dump the traceback on a user signal File descriptor issue --------------------- -:func:`enable`, :func:`dump_tracebacks_later` and :func:`register` keep the +:func:`enable`, :func:`dump_traceback_later` and :func:`register` keep the file descriptor of their *file* argument. If the file is closed and its file descriptor is reused by a new file, or if :func:`os.dup2` is used to replace the file descriptor, the traceback will be written into a different file. Call diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py index c186b34..b81b34d 100644 --- a/Lib/test/test_faulthandler.py +++ b/Lib/test/test_faulthandler.py @@ -407,7 +407,7 @@ Current thread XXX: with temporary_filename() as filename: self.check_dump_traceback_threads(filename) - def _check_dump_tracebacks_later(self, repeat, cancel, filename, loops): + def _check_dump_traceback_later(self, repeat, cancel, filename, loops): """ Check how many times the traceback is written in timeout x 2.5 seconds, or timeout x 3.5 seconds if cancel is True: 1, 2 or 3 times depending @@ -422,11 +422,11 @@ import time def func(timeout, repeat, cancel, file, loops): for loop in range(loops): - faulthandler.dump_tracebacks_later(timeout, repeat=repeat, file=file) + faulthandler.dump_traceback_later(timeout, repeat=repeat, file=file) if cancel: - faulthandler.cancel_dump_tracebacks_later() + faulthandler.cancel_dump_traceback_later() time.sleep(timeout * 5) - faulthandler.cancel_dump_tracebacks_later() + faulthandler.cancel_dump_traceback_later() timeout = {timeout} repeat = {repeat} @@ -462,9 +462,9 @@ if file is not None: self.assertEqual(trace, '') self.assertEqual(exitcode, 0) - @unittest.skipIf(not hasattr(faulthandler, 'dump_tracebacks_later'), - 'need faulthandler.dump_tracebacks_later()') - def check_dump_tracebacks_later(self, repeat=False, cancel=False, + @unittest.skipIf(not hasattr(faulthandler, 'dump_traceback_later'), + 'need faulthandler.dump_traceback_later()') + def check_dump_traceback_later(self, repeat=False, cancel=False, file=False, twice=False): if twice: loops = 2 @@ -472,25 +472,25 @@ if file is not None: loops = 1 if file: with temporary_filename() as filename: - self._check_dump_tracebacks_later(repeat, cancel, + self._check_dump_traceback_later(repeat, cancel, filename, loops) else: - self._check_dump_tracebacks_later(repeat, cancel, None, loops) + self._check_dump_traceback_later(repeat, cancel, None, loops) - def test_dump_tracebacks_later(self): - self.check_dump_tracebacks_later() + def test_dump_traceback_later(self): + self.check_dump_traceback_later() - def test_dump_tracebacks_later_repeat(self): - self.check_dump_tracebacks_later(repeat=True) + def test_dump_traceback_later_repeat(self): + self.check_dump_traceback_later(repeat=True) - def test_dump_tracebacks_later_cancel(self): - self.check_dump_tracebacks_later(cancel=True) + def test_dump_traceback_later_cancel(self): + self.check_dump_traceback_later(cancel=True) - def test_dump_tracebacks_later_file(self): - self.check_dump_tracebacks_later(file=True) + def test_dump_traceback_later_file(self): + self.check_dump_traceback_later(file=True) - def test_dump_tracebacks_later_twice(self): - self.check_dump_tracebacks_later(twice=True) + def test_dump_traceback_later_twice(self): + self.check_dump_traceback_later(twice=True) @unittest.skipIf(not hasattr(faulthandler, "register"), "need faulthandler.register") @@ -127,6 +127,9 @@ Core and Builtins Library ------- +- Issue #5969: faulthandler module: rename dump_tracebacks_later() to + dump_traceback_later() and cancel_dump_tracebacks_later() to + cancel_dump_traceback_later(). What's New in Python 3.3.0 Release Candidate 2? =============================================== diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index 4aa9124..7e363f0 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -462,7 +462,7 @@ faulthandler_thread(void *unused) } static void -cancel_dump_tracebacks_later(void) +cancel_dump_traceback_later(void) { /* Notify cancellation */ PyThread_release_lock(thread.cancel_event); @@ -509,7 +509,7 @@ format_timeout(double timeout) } static PyObject* -faulthandler_dump_tracebacks_later(PyObject *self, +faulthandler_dump_traceback_later(PyObject *self, PyObject *args, PyObject *kwargs) { static char *kwlist[] = {"timeout", "repeat", "file", "exit", NULL}; @@ -524,7 +524,7 @@ faulthandler_dump_tracebacks_later(PyObject *self, size_t header_len; if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "d|iOi:dump_tracebacks_later", kwlist, + "d|iOi:dump_traceback_later", kwlist, &timeout, &repeat, &file, &exit)) return NULL; if ((timeout * 1e6) >= (double) PY_TIMEOUT_MAX) { @@ -552,7 +552,7 @@ faulthandler_dump_tracebacks_later(PyObject *self, header_len = strlen(header); /* Cancel previous thread, if running */ - cancel_dump_tracebacks_later(); + cancel_dump_traceback_later(); Py_XDECREF(thread.file); Py_INCREF(file); @@ -582,9 +582,9 @@ faulthandler_dump_tracebacks_later(PyObject *self, } static PyObject* -faulthandler_cancel_dump_tracebacks_later_py(PyObject *self) +faulthandler_cancel_dump_traceback_later_py(PyObject *self) { - cancel_dump_tracebacks_later(); + cancel_dump_traceback_later(); Py_RETURN_NONE; } #endif /* FAULTHANDLER_LATER */ @@ -970,16 +970,16 @@ static PyMethodDef module_methods[] = { "dump the traceback of the current thread, or of all threads " "if all_threads is True, into file")}, #ifdef FAULTHANDLER_LATER - {"dump_tracebacks_later", - (PyCFunction)faulthandler_dump_tracebacks_later, METH_VARARGS|METH_KEYWORDS, - PyDoc_STR("dump_tracebacks_later(timeout, repeat=False, file=sys.stderrn, exit=False):\n" + {"dump_traceback_later", + (PyCFunction)faulthandler_dump_traceback_later, METH_VARARGS|METH_KEYWORDS, + PyDoc_STR("dump_traceback_later(timeout, repeat=False, file=sys.stderrn, exit=False):\n" "dump the traceback of all threads in timeout seconds,\n" "or each timeout seconds if repeat is True. If exit is True, " "call _exit(1) which is not safe.")}, - {"cancel_dump_tracebacks_later", - (PyCFunction)faulthandler_cancel_dump_tracebacks_later_py, METH_NOARGS, - PyDoc_STR("cancel_dump_tracebacks_later():\ncancel the previous call " - "to dump_tracebacks_later().")}, + {"cancel_dump_traceback_later", + (PyCFunction)faulthandler_cancel_dump_traceback_later_py, METH_NOARGS, + PyDoc_STR("cancel_dump_traceback_later():\ncancel the previous call " + "to dump_traceback_later().")}, #endif #ifdef FAULTHANDLER_USER @@ -1120,7 +1120,7 @@ void _PyFaulthandler_Fini(void) #ifdef FAULTHANDLER_LATER /* later */ if (thread.cancel_event) { - cancel_dump_tracebacks_later(); + cancel_dump_traceback_later(); PyThread_release_lock(thread.cancel_event); PyThread_free_lock(thread.cancel_event); thread.cancel_event = NULL; |