Skip to content

Commit 67b41ca

Browse files
committed
Check if transport has been set when closing
The transport doesn't get set as soon as the response handler is created, it's set some time later. If the handler is closed immediately it can be before the transport has been set, and in that case we don't need it. Fixes #46
1 parent 2f15224 commit 67b41ca

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

custom_components/wundasmart/session.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def __init__(self, *args, **kwargs):
3434
self.__closed_transport = None
3535

3636
def close(self):
37-
self.__closed_transport = weakref.ref(self.transport)
37+
if self.transport is not None:
38+
self.__closed_transport = weakref.ref(self.transport)
3839
super().close()
3940

4041
def connection_lost(self, exc):

0 commit comments

Comments
 (0)