Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.8 warnings #95

Closed
adamchainz opened this issue Jun 17, 2020 · 3 comments · Fixed by #109
Closed

Python 3.8 warnings #95

adamchainz opened this issue Jun 17, 2020 · 3 comments · Fixed by #109
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@adamchainz
Copy link
Contributor

I'm seeing this warning on Python 3.8:

/.../lib/python3.8/site-packages/ocpp/charge_point.py:184: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
  response = await asyncio.coroutine(handler)(**snake_case_payload)

Is there any reason not to convert the associated methods to async def ?

@OrangeTux
Copy link
Contributor

Thanks for the report. This line executes the handlers that are registered for an action. Handlers can be both regular functions as well as async functions. E.g.:

@on("Heartbeat")
def on_heart_beat(*args, **kwargs):
    pass

@on("Heartbeat")
async def on_heart_beat(*args, **kwargs):
    pass

response = await asyncio.coroutine(handler)(**snake_case_payload) makes sure that that both version can be executed.
You state correctly that asyncio.coroutine is depricated. Therefore I think we should replace it with:

response = handler(**snake_case_payload)
if inspect.isawaitable(response):
                 response = await response

@OrangeTux OrangeTux added good first issue Good for newcomers enhancement New feature or request labels Jun 22, 2020
@laysauchoa
Copy link
Contributor

cc @OrangeTux
Hey, is someone working on this ticket?

@OrangeTux
Copy link
Contributor

Nope.

@laysauchoa laysauchoa linked a pull request Sep 6, 2020 that will close this issue
@laysauchoa laysauchoa self-assigned this Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Development

Successfully merging a pull request may close this issue.

3 participants