Hello,

I had opened this bug because I had a bad regex in my code that was causing
python to hang in the regex evaluation: https://bugs.python.org/issue46627.
I have fixed the problem with that specific regex, but more generally I
think it would be good to have a timeout option that could be configurable
when compiling the regex so that if the regex didn't complete within the
specified timeframe, it would abort and throw an exception.

The bug was closed as Won't Fix and it was suggested that I bring up my
idea here. The suggestion made to me on the bug was to read Mastering
Regular Expressions and get better at writing regexes. I will take this
advice, but this isn't really a reasonable solution to my problem for a few
reasons.
My use case is log parsing and I have a large number of regexes that run
over many different log lines. With the volume of regexes I have, it's hard
to make sure every regex has no potential problems, especially when the
pathological behavior only occurs on certain inputs that may not have been
anticipated when developing the regex.
Also because of the volume of data these regexes are parsing, I would never
want to allow a regex to run longer than a few milliseconds because if it
did, that would kill my log processing throughput. I'd rather that it just
raise an exception and move on to the next log entry.
Thanks,
J.B.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/BJJFVT6WECWOWDIMBEHCMYC4V5YCTGFN/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to