Sfoglia il codice sorgente

Simplified handler logic
The direct handler is always a coroutine, no need to perform this additional check.

Stan Janssen 4 anni fa
parent
commit
3a176543fc
1 ha cambiato i file con 1 aggiunte e 5 eliminazioni
  1. 1 5
      pyopenadr/service/vtn_service.py

+ 1 - 5
pyopenadr/service/vtn_service.py

@@ -33,11 +33,7 @@ class VTNService:
 
         if message_type in self.handlers:
             handler = self.handlers[message_type]
-            result = handler(message_payload)
-            if iscoroutine(result):
-                response_type, response_payload = await result
-            else:
-                response_type, response_payload = result
+            response_type, response_payload = await handler(message_payload)
 
             # Get the relevant template and create the XML response
             template = self.templates.get_template(f'{response_type}.xml')