This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author joshhoyt
Recipients
Date 2003-11-21.06:29:21
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
This patch adds a call to PyErr_CheckSignals to
SRE_MATCH so that signal handlers can be invoked during
long regular expression matches. It also adds a new
error return value indicating that an exception
occurred in a signal handler during the match, allowing
exceptions in the signal handler to propagate up to the
main loop.

Rationale:

Regular expressions can run away inside of the C code.
There is no way for Python code to stop the C code from
running away, so we attempted to use setrlimit to
interrupt the process when the CPU usage exceeded a limit.

When the signal was received, the signal function was
triggered. The sre code does not allow the main loop to
run, so the triggered handlers were not called until
the regular expression finished, if ever. This
behaviour makes the interruption by the signal useless
for the purposes of constraining the running time of
regular expression matches.

I am unsure whether the PyErr_CheckSignals is
lightweight enough to be called inside of the for loop
in SRE_MATCH, so I took the conservative approach and
only checked on recursion or match invocation. I
believe that the performance hit from this check would
not be prohibitive inside of the loop, since
PyErr_CheckSignals does very little work unless there
is a signal to handle.
History
Date User Action Args
2007-08-23 15:29:52adminlinkissue846388 messages
2007-08-23 15:29:52admincreate