Exemplo n.º 1
0
class TwistedStreamProcessor(StreamProcessor):

    def __init__(self, api_key, config, store):
        self._store = store
        self.sse_client = TwistedSSEClient(config.stream_uri + "/", headers=_stream_headers(api_key,
                                                                                            "PythonTwistedClient"),
                                           verify=config.verify,
                                           on_event=partial(RequestsStreamProcessor.process_message, self._store))
        self.running = False

    def start(self):
        self.sse_client.start()
        self.running = True

    def stop(self):
        self.sse_client.stop()

    def get_feature(self, key):
        return self._store.get(key)

    def initialized(self):
        return self._store.initialized()

    def is_alive(self):
        return self.running
Exemplo n.º 2
0
 def __init__(self, api_key, config, store):
     self._store = store
     self.sse_client = TwistedSSEClient(config.stream_uri + "/", headers=_stream_headers(api_key,
                                                                                         "PythonTwistedClient"),
                                        verify=config.verify,
                                        on_event=partial(RequestsStreamProcessor.process_message, self._store))
     self.running = False