Is there a way to cancel or timeout a long running regular expression? I have a program that accepts regular expressions from users and I'm concerned about how to handle worst case regular expressions that seem to run forever. Ideally I'm looking for a way to evaluate a regular expression and timeout after a specified time period if the regular expression hasn't completed yet. Or a way for a user to cancel a long running regular expression.
I was thinking there might be a technique I could use to evaluate regular expressions in a thread or another process launched via multiprocessing module and then kill the thread/process after a specified timeout period. My concern about the multiprocessing module technique is that launching a process for every regex evaluation sounds pretty inefficient. And I don't think the threading module supports the ability to kill threads from outside a thread itself. Malcolm
-- http://mail.python.org/mailman/listinfo/python-list