mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Merge pull request #36310 from thatch45/keep_loop
Fix bug where the client will destroy the loop
This commit is contained in:
commit
d0a495f08b
@ -126,7 +126,7 @@ class LocalClient(object):
|
||||
def __init__(self,
|
||||
c_path=os.path.join(syspaths.CONFIG_DIR, 'master'),
|
||||
mopts=None, skip_perm_errors=False,
|
||||
io_loop=None):
|
||||
io_loop=None, keep_loop=False):
|
||||
'''
|
||||
:param IOLoop io_loop: io_loop used for events.
|
||||
Pass in an io_loop if you want asynchronous
|
||||
@ -155,7 +155,8 @@ class LocalClient(object):
|
||||
self.opts['transport'],
|
||||
opts=self.opts,
|
||||
listen=False,
|
||||
io_loop=io_loop)
|
||||
io_loop=io_loop,
|
||||
keep_loop=keep_loop)
|
||||
self.utils = salt.loader.utils(self.opts)
|
||||
self.functions = salt.loader.minion_mods(self.opts, utils=self.utils)
|
||||
self.returners = salt.loader.returners(self.opts, self.functions)
|
||||
|
@ -112,7 +112,7 @@ TAGS = {
|
||||
|
||||
def get_event(
|
||||
node, sock_dir=None, transport='zeromq',
|
||||
opts=None, listen=True, io_loop=None):
|
||||
opts=None, listen=True, io_loop=None, keep_loop=False):
|
||||
'''
|
||||
Return an event object suitable for the named transport
|
||||
|
||||
@ -125,8 +125,8 @@ def get_event(
|
||||
# TODO: AIO core is separate from transport
|
||||
if transport in ('zeromq', 'tcp'):
|
||||
if node == 'master':
|
||||
return MasterEvent(sock_dir, opts, listen=listen, io_loop=io_loop)
|
||||
return SaltEvent(node, sock_dir, opts, listen=listen, io_loop=io_loop)
|
||||
return MasterEvent(sock_dir, opts, listen=listen, io_loop=io_loop, keep_loop=keep_loop)
|
||||
return SaltEvent(node, sock_dir, opts, listen=listen, io_loop=io_loop, keep_loop=keep_loop)
|
||||
elif transport == 'raet':
|
||||
import salt.utils.raetevent
|
||||
return salt.utils.raetevent.RAETEvent(node,
|
||||
@ -177,14 +177,19 @@ class SaltEvent(object):
|
||||
'''
|
||||
def __init__(
|
||||
self, node, sock_dir=None,
|
||||
opts=None, listen=True, io_loop=None):
|
||||
opts=None, listen=True, io_loop=None, keep_loop=False):
|
||||
'''
|
||||
:param IOLoop io_loop: Pass in an io_loop if you want asynchronous
|
||||
operation for obtaining events. Eg use of
|
||||
set_event_handler() API. Otherwise, operation
|
||||
will be synchronous.
|
||||
:param Bool keep_loop: Pass a boolean to determine if we want to keep
|
||||
the io loop or destroy it when the event handle
|
||||
is destroyed. This is useful when using event
|
||||
loops from within third party async code
|
||||
'''
|
||||
self.serial = salt.payload.Serial({'serial': 'msgpack'})
|
||||
self.keep_loop = keep_loop
|
||||
if io_loop is not None:
|
||||
self.io_loop = io_loop
|
||||
self._run_io_loop_sync = False
|
||||
@ -687,7 +692,7 @@ class SaltEvent(object):
|
||||
self.subscriber.close()
|
||||
if self.pusher is not None:
|
||||
self.pusher.close()
|
||||
if self._run_io_loop_sync:
|
||||
if self._run_io_loop_sync and not self.keep_loop:
|
||||
self.io_loop.close()
|
||||
|
||||
def fire_ret_load(self, load):
|
||||
@ -750,9 +755,20 @@ class MasterEvent(SaltEvent):
|
||||
RAET compatible
|
||||
Create a master event management object
|
||||
'''
|
||||
def __init__(self, sock_dir, opts=None, listen=True, io_loop=None):
|
||||
def __init__(
|
||||
self,
|
||||
sock_dir,
|
||||
opts=None,
|
||||
listen=True,
|
||||
io_loop=None,
|
||||
keep_loop=False):
|
||||
super(MasterEvent, self).__init__(
|
||||
'master', sock_dir, opts, listen=listen, io_loop=io_loop)
|
||||
'master',
|
||||
sock_dir,
|
||||
opts,
|
||||
listen=listen,
|
||||
io_loop=io_loop,
|
||||
keep_loop=keep_loop)
|
||||
|
||||
|
||||
class LocalClientEvent(MasterEvent):
|
||||
|
Loading…
Reference in New Issue
Block a user