Remove procpool references from batchprocessor. Resolves #2145.
This commit is contained in:
parent
5e6c52e2e6
commit
efc9b87099
1 changed files with 21 additions and 100 deletions
|
|
@ -50,35 +50,6 @@ _UTF8_ERROR = """
|
||||||
Error reported was: '%s'
|
Error reported was: '%s'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_PROCPOOL_BATCHCMD_SOURCE = """
|
|
||||||
from evennia.commands.default.batchprocess import batch_cmd_exec, step_pointer, BatchSafeCmdSet
|
|
||||||
caller.ndb.batch_stack = commands
|
|
||||||
caller.ndb.batch_stackptr = 0
|
|
||||||
caller.ndb.batch_batchmode = "batch_commands"
|
|
||||||
caller.cmdset.add(BatchSafeCmdSet)
|
|
||||||
for inum in range(len(commands)):
|
|
||||||
print "command:", inum
|
|
||||||
caller.cmdset.add(BatchSafeCmdSet)
|
|
||||||
if not batch_cmd_exec(caller):
|
|
||||||
break
|
|
||||||
step_pointer(caller, 1)
|
|
||||||
print "leaving run ..."
|
|
||||||
"""
|
|
||||||
_PROCPOOL_BATCHCODE_SOURCE = """
|
|
||||||
from evennia.commands.default.batchprocess import batch_code_exec, step_pointer, BatchSafeCmdSet
|
|
||||||
caller.ndb.batch_stack = codes
|
|
||||||
caller.ndb.batch_stackptr = 0
|
|
||||||
caller.ndb.batch_batchmode = "batch_code"
|
|
||||||
caller.cmdset.add(BatchSafeCmdSet)
|
|
||||||
for inum in range(len(codes)):
|
|
||||||
print "code:", inum
|
|
||||||
caller.cmdset.add(BatchSafeCmdSet)
|
|
||||||
if not batch_code_exec(caller):
|
|
||||||
break
|
|
||||||
step_pointer(caller, 1)
|
|
||||||
print "leaving run ..."
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# Helper functions
|
# Helper functions
|
||||||
|
|
@ -300,42 +271,17 @@ class CmdBatchCommands(_COMMAND_DEFAULT_CLASS):
|
||||||
"for %s (this might take some time) ..." % python_path
|
"for %s (this might take some time) ..." % python_path
|
||||||
)
|
)
|
||||||
|
|
||||||
procpool = False
|
# run in-process (might block)
|
||||||
if "PythonProcPool" in utils.server_services():
|
for _ in range(len(commands)):
|
||||||
if utils.uses_database("sqlite3"):
|
# loop through the batch file
|
||||||
caller.msg("Batchprocessor disabled ProcPool under SQLite3.")
|
if not batch_cmd_exec(caller):
|
||||||
else:
|
return
|
||||||
procpool = True
|
step_pointer(caller, 1)
|
||||||
|
# clean out the safety cmdset and clean out all other
|
||||||
if procpool:
|
# temporary attrs.
|
||||||
# run in parallel process
|
string = " Batchfile '%s' applied." % python_path
|
||||||
def callback(r):
|
caller.msg("|G%s" % string)
|
||||||
caller.msg(" |GBatchfile '%s' applied." % python_path)
|
purge_processor(caller)
|
||||||
purge_processor(caller)
|
|
||||||
|
|
||||||
def errback(e):
|
|
||||||
caller.msg(" |RError from processor: '%s'" % e)
|
|
||||||
purge_processor(caller)
|
|
||||||
|
|
||||||
utils.run_async(
|
|
||||||
_PROCPOOL_BATCHCMD_SOURCE,
|
|
||||||
commands=commands,
|
|
||||||
caller=caller,
|
|
||||||
at_return=callback,
|
|
||||||
at_err=errback,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
# run in-process (might block)
|
|
||||||
for _ in range(len(commands)):
|
|
||||||
# loop through the batch file
|
|
||||||
if not batch_cmd_exec(caller):
|
|
||||||
return
|
|
||||||
step_pointer(caller, 1)
|
|
||||||
# clean out the safety cmdset and clean out all other
|
|
||||||
# temporary attrs.
|
|
||||||
string = " Batchfile '%s' applied." % python_path
|
|
||||||
caller.msg("|G%s" % string)
|
|
||||||
purge_processor(caller)
|
|
||||||
|
|
||||||
|
|
||||||
class CmdBatchCode(_COMMAND_DEFAULT_CLASS):
|
class CmdBatchCode(_COMMAND_DEFAULT_CLASS):
|
||||||
|
|
@ -420,41 +366,16 @@ class CmdBatchCode(_COMMAND_DEFAULT_CLASS):
|
||||||
else:
|
else:
|
||||||
caller.msg("Running Batch-code processor - Automatic mode for %s ..." % python_path)
|
caller.msg("Running Batch-code processor - Automatic mode for %s ..." % python_path)
|
||||||
|
|
||||||
procpool = False
|
for _ in range(len(codes)):
|
||||||
if "PythonProcPool" in utils.server_services():
|
# loop through the batch file
|
||||||
if utils.uses_database("sqlite3"):
|
if not batch_code_exec(caller):
|
||||||
caller.msg("Batchprocessor disabled ProcPool under SQLite3.")
|
return
|
||||||
else:
|
step_pointer(caller, 1)
|
||||||
procpool = True
|
# clean out the safety cmdset and clean out all other
|
||||||
if procpool:
|
# temporary attrs.
|
||||||
# run in parallel process
|
string = " Batchfile '%s' applied." % python_path
|
||||||
def callback(r):
|
caller.msg("|G%s" % string)
|
||||||
caller.msg(" |GBatchfile '%s' applied." % python_path)
|
purge_processor(caller)
|
||||||
purge_processor(caller)
|
|
||||||
|
|
||||||
def errback(e):
|
|
||||||
caller.msg(" |RError from processor: '%s'" % e)
|
|
||||||
purge_processor(caller)
|
|
||||||
|
|
||||||
utils.run_async(
|
|
||||||
_PROCPOOL_BATCHCODE_SOURCE,
|
|
||||||
codes=codes,
|
|
||||||
caller=caller,
|
|
||||||
at_return=callback,
|
|
||||||
at_err=errback,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
# un in-process (will block)
|
|
||||||
for _ in range(len(codes)):
|
|
||||||
# loop through the batch file
|
|
||||||
if not batch_code_exec(caller):
|
|
||||||
return
|
|
||||||
step_pointer(caller, 1)
|
|
||||||
# clean out the safety cmdset and clean out all other
|
|
||||||
# temporary attrs.
|
|
||||||
string = " Batchfile '%s' applied." % python_path
|
|
||||||
caller.msg("|G%s" % string)
|
|
||||||
purge_processor(caller)
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue