Skip to content

Commit

Permalink
Merge pull request #82 from mill1000/issue/runtime_error_with_lock
Browse files Browse the repository at this point in the history
Fix issue with lock creation in discover.py
  • Loading branch information
mill1000 authored Oct 12, 2023
2 parents 97d10ac + 97564b5 commit 22992c0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion msmart/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class Discover:

_account = OPEN_MIDEA_APP_ACCOUNT
_password = OPEN_MIDEA_APP_PASSWORD
_lock = asyncio.Lock()
_lock = None
_cloud = None
_auto_connect = False

Expand All @@ -155,6 +155,10 @@ async def discover(
) -> List[Device]:
"""Discover devices via broadcast."""

# Create lock if nonexistent within the context of the current loop
if cls._lock is None:
cls._lock = asyncio.Lock()

# Always use a new cloud connection
cls._cloud = None

Expand Down

0 comments on commit 22992c0

Please sign in to comment.