Skip to content

Commit

Permalink
Moved initialization in client.py
Browse files Browse the repository at this point in the history
  • Loading branch information
corporategoth committed Jan 1, 2024
1 parent 5c40431 commit be505a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
32 changes: 16 additions & 16 deletions custom_components/powerpetdoor/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,22 @@ def __init__(self, host: str, port: int, keepalive: float, timeout: float,
self.cfg_timeout = timeout
self.cfg_reconnect = reconnect

self._shutdown = False
self._ownLoop = False
self._eventLoop = None
self._transport = None
self._keepalive = None
self._check_receipt = None
self._last_ping = None
self._last_command = None
self._can_dequeue = False
self._last_send = 0
self._failed_msg = 0
self._failed_pings = 0
self._buffer = ''
self._outstanding = {}
self._queue = queue.SimpleQueue()

if loop:
_LOGGER.info("Latching onto an existing event loop.")
self._ownLoop = False
Expand Down Expand Up @@ -178,22 +194,6 @@ def __init__(self, host: str, port: int, keepalive: float, timeout: float,
self.on_disconnect: dict[str, Callable[[], Awaitable[None]]] = {}
self.on_ping: dict[str, Callable[[int], None]] = {}

self._shutdown = False
self._ownLoop = False
self._eventLoop = None
self._transport = None
self._keepalive = None
self._check_receipt = None
self._last_ping = None
self._last_command = None
self._can_dequeue = False
self._last_send = 0
self._failed_msg = 0
self._failed_pings = 0
self._buffer = ''
self._outstanding = {}
self._queue = queue.SimpleQueue()

# Theses functions wrap asyncio but ensure the loop is correct!
def ensure_future(self, *args: Any, **kwargs: Any):
return asyncio.ensure_future(*args, loop=self._eventLoop, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/powerpetdoor/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"issue_tracker": "https://github.com/corporategoth/ha-powerpetdoor/issues",
"quality_scale": "gold",
"requirements": [],
"version": "0.4.4"
"version": "0.4.5"
}

0 comments on commit be505a1

Please sign in to comment.