Example #1
0
 def __init__(self, func, interval=0.1, threads=1):
     self.lock = Lock()
     self.threads = []
     self.stopped = Event()
     self.func, self.interval, self.thread_count = func, interval, threads
     on_startup(self.start)
     on_shutdown(self.stop)
Example #2
0
 def __init__(self, hostnames, rpc_method, *args, **kwargs):
     from sideboard.lib import listify
     self.hostnames, self.method, self.args, self.kwargs = listify(
         hostnames), rpc_method, args, kwargs
     self.results, self.websockets, self._client_ids = {}, {}, {}
     on_startup(self._subscribe)
     on_shutdown(self._unsubscribe)
Example #3
0
    def __init__(self, func, interval=None, threads=1, name=None):
        self.lock = Lock()
        self.threads = []
        self.stopped = Event()
        self.func, self.interval, self.thread_count = func, interval, threads
        self.name = name or self.func.__name__

        on_startup(self.start)
        on_shutdown(self.stop)
Example #4
0
 def __init__(self, rpc_method, *args, **kwargs):
     self.result = None
     connect_immediately = kwargs.pop('connect_immediately', False)
     self.method, self.args, self.kwargs = rpc_method, args, kwargs
     self.ws = sideboard.lib.services.get_websocket(rpc_method.split('.')[0])
     on_startup(self._subscribe)
     on_shutdown(self._unsubscribe)
     if connect_immediately:
         self.ws.connect(max_wait=2)
         self._subscribe()
Example #5
0
 def __init__(self, rpc_method, *args, **kwargs):
     self.result = None
     connect_immediately = kwargs.pop('connect_immediately', False)
     self.method, self.args, self.kwargs = rpc_method, args, kwargs
     self.ws = sideboard.lib.services.get_websocket(rpc_method.split('.')[0])
     on_startup(self._subscribe)
     on_shutdown(self._unsubscribe)
     if connect_immediately:
         self.ws.connect(max_wait=2)
         self._subscribe()
Example #6
0
 def __init__(self, url=None):
     self.ws = None
     self.url = url or self.default_url
     assert self.url, 'no url or default url provided'
     self._lock = RLock()
     self._callbacks = {}
     self._counter = count()
     self._reconnect_attempts = 0
     self._last_poll, self._last_reconnect_attempt = None, None
     self._checker = threads.DaemonTask(self._check, interval=1)
     self._dispatcher = threads.Caller(self._dispatch, threads=1)
     self._dispatcher.start()
     self._checker.start()
     on_shutdown(self._checker.stop)
     on_shutdown(self._dispatcher.stop)
Example #7
0
 def __init__(self, rpc_method, *args, **kwargs):
     self.ws = None
     self.method, self.args, self.kwargs = rpc_method, args, kwargs
     on_startup(self.connect)
     on_shutdown(self.disconnect)
Example #8
0
 def __init__(self, hostnames, rpc_method, *args, **kwargs):
     from sideboard.lib import listify
     self.hostnames, self.method, self.args, self.kwargs = listify(hostnames), rpc_method, args, kwargs
     self.results, self.websockets, self._client_ids = {}, {}, {}
     on_startup(self._subscribe)
     on_shutdown(self._unsubscribe)