Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Use kuksa-client as non context-manager #526

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions kuksa-client/kuksa_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

from . import cli_backend


class KuksaClientThread(threading.Thread):

# Constructor
Expand Down Expand Up @@ -86,17 +87,23 @@ def getValues(self, paths: Iterable[str], attribute="value", timeout=5):
# The given callback function will be called then, if the given path is updated:
# updateMessage = await webSocket.recv()
# callback(updateMessage)
def subscribe(self, path, callback, attribute = "value", timeout=5):
def subscribe(self, path, callback, attribute="value", timeout=5):
return self.backend.subscribe(path, callback, attribute, timeout)

def subscribeMultiple(self, paths, callback, attribute = "value", timeout=5):
def subscribeMultiple(self, paths, callback, attribute="value", timeout=5):
return self.backend.subscribeMultiple(paths, callback, attribute, timeout)

# Unsubscribe value changes of to a given path.
# The subscription id from the response of the corresponding subscription request will be required
def unsubscribe(self, sub_id, timeout=5):
return self.backend.unsubscribe(sub_id, timeout)

def disconnect(self, timeout=5):
return self.backend.disconnect(timeout)

def connect(self, timeout=5):
SebastianSchildt marked this conversation as resolved.
Show resolved Hide resolved
return self.backend.connect(timeout)

# Thread function: Start the asyncio loop
def run(self):
self.loop = asyncio.new_event_loop()
Expand Down
Loading