mirror of https://github.com/Mikaela/Limnoria.git
regexp_wrapper: return None instead of False when search times out (#1379)
This allows plugins to detect whether a search timed out or did not match, which are two distinct outcomes.
This commit is contained in:
parent
27e7d6a9ac
commit
b54d8f8073
|
@ -149,7 +149,7 @@ def process(f, *args, **kwargs):
|
||||||
|
|
||||||
def regexp_wrapper(s, reobj, timeout, plugin_name, fcn_name):
|
def regexp_wrapper(s, reobj, timeout, plugin_name, fcn_name):
|
||||||
'''A convenient wrapper to stuff regexp search queries through a subprocess.
|
'''A convenient wrapper to stuff regexp search queries through a subprocess.
|
||||||
|
|
||||||
This is used because specially-crafted regexps can use exponential time
|
This is used because specially-crafted regexps can use exponential time
|
||||||
and hang the bot.'''
|
and hang the bot.'''
|
||||||
def re_bool(s, reobj):
|
def re_bool(s, reobj):
|
||||||
|
@ -163,7 +163,7 @@ def regexp_wrapper(s, reobj, timeout, plugin_name, fcn_name):
|
||||||
v = process(re_bool, s, reobj, timeout=timeout, pn=plugin_name, cn=fcn_name)
|
v = process(re_bool, s, reobj, timeout=timeout, pn=plugin_name, cn=fcn_name)
|
||||||
return v
|
return v
|
||||||
except ProcessTimeoutError:
|
except ProcessTimeoutError:
|
||||||
return False
|
return None
|
||||||
|
|
||||||
class UrlSnarfThread(world.SupyThread):
|
class UrlSnarfThread(world.SupyThread):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
Loading…
Reference in New Issue