-
Notifications
You must be signed in to change notification settings - Fork 51
Use kuksa-client as non context-manager #526
Use kuksa-client as non context-manager #526
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling quit in kuksa-client yields exception:
Test Client> quit
Traceback (most recent call last):
File "/Users/scs2rng/.local/share/virtualenvs/testkc-dPiaaAKY/bin/kuksa-client", line 8, in <module>
sys.exit(main())
File "/Users/scs2rng/Documents/Dev/kuksa.val/kuksa-client/kuksa_client/__main__.py", line 550, in main
clientApp.stop()
File "/Users/scs2rng/Documents/Dev/kuksa.val/kuksa-client/kuksa_client/__main__.py", line 384, in stop
self.commThread.stop()
File "/Users/scs2rng/Documents/Dev/kuksa.val/kuksa-client/kuksa_client/__init__.py", line 51, in stop
self.backend.stop()
AttributeError: 'Backend' object has no attribute 'stop'
Started some testing on async side, first example (shortened), works when chaign from async with VSSClient('127.0.0.1', 55557) as client:
current_values = await client.get_current_values([
'Vehicle.Speed',
])
print(current_values['Vehicle.Speed'].value) to myclient=VSSClient('127.0.0.1', 55557)
await myclient.connect()
current_values = await myclient.get_current_values([
'Vehicle.Speed',
])
print(current_values['Vehicle.Speed'].value) Both version work, however subscription is broken, the vanilla example (complete) import asyncio
from kuksa_client.grpc import Datapoint
from kuksa_client.grpc.aio import VSSClient
async def main():
async with VSSClient('127.0.0.1', 55557) as client:
await client.set_target_values({
'Vehicle.Body.Windshield.Front.Wiping.System.TargetPosition': Datapoint(45),
})
async for updates in client.subscribe_current_values([
'Vehicle.Body.Windshield.Front.Wiping.System.TargetPosition',
]):
current_position = updates['Vehicle.Body.Windshield.Front.Wiping.System.TargetPosition'].value
print(f"Current wiper position is: {current_position}")
asyncio.run(main()) fails with
It works well with the released version for kuksa-client (may only complain a None Type is returned, if the value has not been set before) |
I see, will dig deeper into this issue. |
0788926
to
8e290b0
Compare
This PR ignores tests for authorize function as this is part of #517 |
8e290b0
to
8de9460
Compare
ea1b0bb
to
c83cae8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works, but I do think it is not ideal that the CLI exposed to the user has (dis)connectThread and (dis)connect functions that do slightly different things.
I think I want to connect
(and maybe disconnect
, although likely I'll just call another connect instead), and I feel those functions should be doing what the "thread" versions are doing now (at least in the connect case)
Agreed, what do you mean by |
I mean in a workflow I will likely do setServerAdress ... and then connect, I then might do another setServerAdress (to a different location) and call connect again. I would assume it disconnects the previous connection automatically before reconnecting. Therefore, It hink while having a disconnect is consistent and does not hurt, people will likely not use it very often (and should not be "required" to do so, when they decide to connect to a different location) |
Tested and works as you expected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me, tested client and (a)sync examples
lgtm 🐢
This solves #476