Skip to content

Commit

Permalink
Use create_task when executing the 'after' handler coroutine (#27)
Browse files Browse the repository at this point in the history
* Use create_task when executing the 'after' handler coroutine

* use ensure_future for backwards compatibility
  • Loading branch information
proelke authored Sep 25, 2019
1 parent 4e92dfa commit 873b2eb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ocpp/v16/charge_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ async def _handle_call(self, msg):

try:
handler = handlers['_after_action']
await asyncio.coroutine(handler)(**snake_case_payload)
# Create task to avoid blocking when making a call inside the
# after handler
asyncio.ensure_future(
asyncio.coroutine(handler)(**snake_case_payload))
except KeyError:
# '_on_after' hooks are not required. Therefore ignore exception
# when no '_on_after' hook is installed.
Expand Down

0 comments on commit 873b2eb

Please sign in to comment.