MCPcopy
hub / github.com/saltstack/salt / asynchronous

Method asynchronous

salt/client/mixins.py:584–616  ·  view source on GitHub ↗

Execute the function in a multiprocess and return the event tag to use to watch for the return

(self, fun, low, user="UNKNOWN", pub=None, local=True)

Source from the content-addressed store, hash-verified

582 return {"tag": tag, "jid": jid}
583
584 def asynchronous(self, fun, low, user="UNKNOWN", pub=None, local=True):
585 """
586 Execute the function in a multiprocess and return the event tag to use
587 to watch for the return
588 """
589 if local:
590 proc_func = self._proc_function
591 else:
592 proc_func = self._proc_function_remote
593 async_pub = pub if pub is not None else self._gen_async_pub()
594 if salt.utils.platform.spawning_platform():
595 instance = None
596 else:
597 instance = self
598 with salt.utils.process.default_signals(signal.SIGINT, signal.SIGTERM):
599 proc = salt.utils.process.SignalHandlingProcess(
600 target=proc_func,
601 name="ProcessFunc({}, fun={} jid={})".format(
602 proc_func.__qualname__, fun, async_pub["jid"]
603 ),
604 kwargs=dict(
605 instance=instance,
606 opts=self.opts,
607 fun=fun,
608 low=low,
609 user=user,
610 tag=async_pub["tag"],
611 jid=async_pub["jid"],
612 ),
613 )
614 proc.start()
615 proc.join() # MUST join, otherwise we leave zombies all over
616 return async_pub
617
618 def print_async_event(self, suffix, event):
619 """

Callers 4

runnerMethod · 0.80
runMethod · 0.80
cmd_asyncMethod · 0.80
runnerMethod · 0.80

Calls 3

_gen_async_pubMethod · 0.95
startMethod · 0.95
formatMethod · 0.80

Tested by

no test coverage detected