mobilityhouse / ocpp

Python implementation of the Open Charge Point Protocol (OCPP).
MIT License
782 stars 306 forks source link

Blocking call detected #647

Open drc38 opened 3 months ago

drc38 commented 3 months ago

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

drc38 commented 3 months ago

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

koopee commented 3 months ago

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...