jamesremuscat / pyze

Unofficial Python client and API for Renault ZE
MIT License
111 stars 29 forks source link

Implement Asynchronous support #70

Closed epenet closed 3 years ago

epenet commented 4 years ago

For issue #60

Following comments on PR #63, I have reworked the architecture so that Sync methods are only wrappers around Async methods (using async_to_sync from asgiref)

It can be tested easily like this:

from api import Vehicle
import asyncio

async def main():
    v = Vehicle('VFxxxxx')
    print(await v.battery_status_async())

asyncio.run(main())
jamesremuscat commented 4 years ago

Hi @epenet,

Sorry it's taken me so long to look at this PR again.

There are some conflicts now with develop since your other PRs have been merged, as well as some Kamereon and Gigya API changes. I had a go at resolving these but I've clearly missed something because I just get:

$ pyze
Traceback (most recent call last):
  File "/home/james/workspace/pyze/venv/bin/pyze", line 11, in <module>
    load_entry_point('PyZE', 'console_scripts', 'pyze')()
  File "/home/james/workspace/pyze/src/pyze/cli/__main__.py", line 69, in main
    parsed_args.func(parsed_args)
  File "/home/james/workspace/pyze/src/pyze/cli/status.py", line 35, in run
    v = get_vehicle(parsed_args)
  File "/home/james/workspace/pyze/src/pyze/cli/common.py", line 24, in get_vehicle
    vehicles = k.get_vehicles().get('vehicleLinks')
AttributeError: 'coroutine' object has no attribute 'get'
sys:1: RuntimeWarning: coroutine 'requires_credentials.<locals>._requires_credential' was never awaited

which I assume means I'm Doing It Wrong™. Please could you take a look?

epenet commented 4 years ago

Let's keep this PR for another release - I know a lot of people are waiting for a publish of the Gigya fix...