Added per-process timeout capability to run_async. Also changed contrib/evlang to use run_async
This commit is contained in:
parent
5c6ee44039
commit
81dfeb6788
3 changed files with 30 additions and 13 deletions
|
|
@ -806,7 +806,7 @@ def validate_code(codestring):
|
|||
raise LimitedExecCodeException(codestring, checker.errors)
|
||||
return True
|
||||
|
||||
def limited_exec(code, context = {}, timeout_secs = 2, retobj=None):
|
||||
def limited_exec(code, context = {}, timeout_secs=2, retobj=None):
|
||||
"""
|
||||
Validate source code and make sure it contains no unauthorized
|
||||
expression/statements as configured via 'UNALLOWED_AST_NODES' and
|
||||
|
|
@ -833,7 +833,7 @@ def limited_exec(code, context = {}, timeout_secs = 2, retobj=None):
|
|||
errback = lambda e: retobj.msg(e)
|
||||
# run code only after validation has completed
|
||||
if validate_context(context) and validate_code(code):
|
||||
run_async(code, *context, at_return=callback, at_err=errback)
|
||||
run_async(code, *context, proc_timeout=timeout_secs, at_return=callback, at_err=errback)
|
||||
else:
|
||||
# run code only after validation has completed
|
||||
if validate_context(context) and validate_code(code):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue