diff --git a/ocpp/charge_point.py b/ocpp/charge_point.py index 736c10f66..7314804b1 100644 --- a/ocpp/charge_point.py +++ b/ocpp/charge_point.py @@ -295,7 +295,9 @@ async def _handle_call(self, msg): return if not handlers.get("_skip_schema_validation", False): - validate_payload(msg, self._ocpp_version) + await asyncio.get_event_loop().run_in_executor( + None, validate_payload, msg, self._ocpp_version + ) # OCPP uses camelCase for the keys in the payload. It's more pythonic # to use snake_case for keyword arguments. Therefore the keys must be # 'translated'. Some examples: @@ -342,7 +344,9 @@ async def _handle_call(self, msg): response = msg.create_call_result(camel_case_payload) if not handlers.get("_skip_schema_validation", False): - validate_payload(response, self._ocpp_version) + await asyncio.get_event_loop().run_in_executor( + None, validate_payload, response, self._ocpp_version + ) await self._send(response.to_json()) @@ -411,7 +415,9 @@ async def call( ) if not skip_schema_validation: - validate_payload(call, self._ocpp_version) + await asyncio.get_event_loop().run_in_executor( + None, validate_payload, call, self._ocpp_version + ) # Use a lock to prevent make sure that only 1 message can be send at a # a time. @@ -434,7 +440,9 @@ async def call( raise response.to_exception() elif not skip_schema_validation: response.action = call.action - validate_payload(response, self._ocpp_version) + await asyncio.get_event_loop().run_in_executor( + None, validate_payload, response, self._ocpp_version + ) snake_case_payload = camel_to_snake_case(response.payload) # Create the correct Payload instance based on the received payload. If