From 7c9c59308e2284a9807e1a1e21cc93bc00bbf138 Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Thu, 12 Dec 2019 22:20:16 +0100 Subject: [PATCH] `create_tcp_dsmr_reader` accepts `loop=None` but always expects a loop. Fixes #36 --- dsmr_parser/clients/protocol.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dsmr_parser/clients/protocol.py b/dsmr_parser/clients/protocol.py index 141a389..2c9650e 100644 --- a/dsmr_parser/clients/protocol.py +++ b/dsmr_parser/clients/protocol.py @@ -49,12 +49,13 @@ def create_dsmr_reader(port, dsmr_version, telegram_callback, loop=None): def create_tcp_dsmr_reader(host, port, dsmr_version, telegram_callback, loop=None): """Creates a DSMR asyncio protocol coroutine using TCP connection.""" + if not loop: + loop = asyncio.get_event_loop() protocol, _ = create_dsmr_protocol( - dsmr_version, telegram_callback, loop=None) + dsmr_version, telegram_callback, loop=loop) conn = loop.create_connection(protocol, host, port) return conn - class DSMRProtocol(asyncio.Protocol): """Assemble and handle incoming data into complete DSM telegrams."""