Timeout for regular expression

C

citronelu

Hi All,

Is there a way to set a timeout interval when executing with a
re.search ? Sometimes (reason being maybe a "bad" pattern), the search
takes forever and beyond...
 
F

Fredrik Lundh

Is there a way to set a timeout interval when executing with a
re.search ? Sometimes (reason being maybe a "bad" pattern),
the search takes forever and beyond...

not directly. the only reliable way is to run it in a separate process,
and use the resource module to set necessary limits.

(to figure out if an expression can take lots of time, look for nested
repeats. analyzing the output from sre_parse.parse(pattern) makes
that relatively easy).

</F>
 
T

Terry Hancock

not directly. the only reliable way is to run it in a
separate process, and use the resource module to set
necessary limits.

Wow. Thank you Mr. Lundh, I never noticed that module. I
think I have an application for that.

Cheers,
Terry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,270
Messages
2,571,353
Members
48,038
Latest member
HunterDela

Latest Threads

Top