Blocking call detected
The ocpp integration (https://github.com/lbbrhzn/ocpp) using this library in Home Assistant 2024.06 has detected that the IO open file call in messages.py blocks the event loop.
Would it make sense in charge_point.py to replace calls to validate_payload with the equivalent run in the executor eg await asyncio.get_event_loop().run_in_executor(...,validate_payload,...)?
Or if you have suggestions on how it can be addressed another way that would be great.
Many thanks
Confirmed replacing the calls (eg the below example) fixes the blocking error:
await asyncio.get_event_loop().run_in_executor(
None,
validate_payload,
msg,
self._ocpp_version
)
Let me know if you want me to submit a PR
Confirmed replacing the calls (eg the below example) fixes the blocking error:
await asyncio.get_event_loop().run_in_executor( None, validate_payload, msg, self._ocpp_version )Let me know if you want me to submit a PR
I don't really know how the process works, but maybe you should submit PR...
FIxed in https://github.com/mobilityhouse/ocpp/pull/652
I am requesting a revert of this code, see https://github.com/mobilityhouse/ocpp/pull/676 .
I think the original report should be clarified: Is really the open() system call a problem, or subsequent calls? It is a very strange limitation of not being able to use "open" in an asyncio application. For long running executions and heavy IO usage, it is possible to yield to event loop with asyncio.sleep(0).