Pass batch execution kwargs when doing that via subprocess
i.e. instead of the normal in-app method
This commit is contained in:
parent
a5f04b6c7f
commit
06bedf6cb4
|
@ -28,6 +28,7 @@ from __future__ import unicode_literals, absolute_import
|
|||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import datetime
|
||||
import logging
|
||||
import socket
|
||||
|
@ -804,7 +805,9 @@ class BatchMasterView(MasterView):
|
|||
thread.start()
|
||||
|
||||
# launch thread to invoke handler action
|
||||
thread = Thread(target=self.action_subprocess_thread, args=(batch.uuid, port, username, batch_action, progress))
|
||||
thread = Thread(target=self.action_subprocess_thread,
|
||||
args=(batch.uuid, port, username, batch_action, progress),
|
||||
kwargs=kwargs)
|
||||
thread.start()
|
||||
|
||||
else: # either versioning is disabled, or handler doesn't mind
|
||||
|
@ -919,7 +922,7 @@ class BatchMasterView(MasterView):
|
|||
log.debug("launching command in subprocess: %s", cmd)
|
||||
subprocess.check_call(cmd)
|
||||
|
||||
def action_subprocess_thread(self, batch_uuid, port, username, action, progress):
|
||||
def action_subprocess_thread(self, batch_uuid, port, username, action, progress, **kwargs):
|
||||
"""
|
||||
This method is sort of an alternative thread target for batch actions,
|
||||
to be used in the event versioning is enabled for the main process but
|
||||
|
@ -927,6 +930,18 @@ class BatchMasterView(MasterView):
|
|||
launch a separate process with versioning disabled in order to act on
|
||||
the batch.
|
||||
"""
|
||||
# figure out the (sub)command args we'll be passing
|
||||
subargs = [
|
||||
'--batch-type',
|
||||
self.handler.batch_key,
|
||||
batch_uuid,
|
||||
]
|
||||
if action == 'execute' and kwargs:
|
||||
subargs.extend([
|
||||
'--kwargs',
|
||||
json.dumps(kwargs),
|
||||
])
|
||||
|
||||
# invoke command to act on batch in separate process
|
||||
try:
|
||||
self.launch_subprocess(port=port, username=username,
|
||||
|
@ -935,11 +950,7 @@ class BatchMasterView(MasterView):
|
|||
'--no-versioning',
|
||||
],
|
||||
subcommand='{}-batch'.format(action),
|
||||
subcommand_args=[
|
||||
'--batch-type',
|
||||
self.handler.batch_key,
|
||||
batch_uuid,
|
||||
])
|
||||
subcommand_args=subargs)
|
||||
except Exception as error:
|
||||
log.warning("%s of '%s' batch failed: %s", action, self.handler.batch_key, batch_uuid, exc_info=True)
|
||||
|
||||
|
|
Loading…
Reference in a new issue