Some fixes for using evlang without ProcPool.
This commit is contained in:
parent
81dfeb6788
commit
12523c81b6
1 changed files with 13 additions and 10 deletions
|
|
@ -85,6 +85,8 @@ from django.core.management import setup_environ
|
||||||
from game import settings
|
from game import settings
|
||||||
setup_environ(settings)
|
setup_environ(settings)
|
||||||
from src.utils.utils import run_async
|
from src.utils.utils import run_async
|
||||||
|
|
||||||
|
_PROCPOOL_ENABLED = settings.PROCPOOL_ENABLED
|
||||||
_LOGGER = None
|
_LOGGER = None
|
||||||
|
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
|
|
@ -828,17 +830,18 @@ def limited_exec(code, context = {}, timeout_secs=2, retobj=None):
|
||||||
if code did not execute within the given timelimit =
|
if code did not execute within the given timelimit =
|
||||||
LimitedExecTimeoutException
|
LimitedExecTimeoutException
|
||||||
"""
|
"""
|
||||||
if retobj:
|
if validate_context(context) and validate_code(code):
|
||||||
callback = lambda r: retobj.msg(r)
|
|
||||||
errback = lambda e: retobj.msg(e)
|
|
||||||
# run code only after validation has completed
|
# run code only after validation has completed
|
||||||
if validate_context(context) and validate_code(code):
|
if _PROCPOOL_ENABLED:
|
||||||
run_async(code, *context, proc_timeout=timeout_secs, at_return=callback, at_err=errback)
|
if retobj:
|
||||||
else:
|
callback = lambda r: retobj.msg(r)
|
||||||
# run code only after validation has completed
|
errback = lambda e: retobj.msg(e)
|
||||||
if validate_context(context) and validate_code(code):
|
run_async(code, *context, proc_timeout=timeout_secs, at_return=callback, at_err=errback)
|
||||||
run_async(code, *context)
|
else:
|
||||||
|
run_async(code, *context, proc_timeout=timeout_secs)
|
||||||
|
else:
|
||||||
|
# run in-process
|
||||||
|
exec code in context
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue