projects
/
python_utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
07a9659
)
Don't let chromecasts steal the thread for too long.
author
Scott
<
[email protected]
>
Tue, 18 Jan 2022 23:18:21 +0000
(15:18 -0800)
committer
Scott
<
[email protected]
>
Tue, 18 Jan 2022 23:18:21 +0000
(15:18 -0800)
smart_home/chromecasts.py
patch
|
blob
|
history
diff --git
a/smart_home/chromecasts.py
b/smart_home/chromecasts.py
index 5e11ac011212e87d9f251cb4743d2fdf6698888a..7480cecc36826932ba90d69ecc83f70cf1a43a97 100644
(file)
--- a/
smart_home/chromecasts.py
+++ b/
smart_home/chromecasts.py
@@
-5,7
+5,6
@@
import atexit
import datetime
import logging
import atexit
import datetime
import logging
-import time
import pychromecast
import pychromecast
@@
-29,7
+28,11
@@
class BaseChromecast(dev.Device):
or (now - BaseChromecast.refresh_ts).total_seconds() > 60
):
logger.debug('Refreshing the shared chromecast info list')
or (now - BaseChromecast.refresh_ts).total_seconds() > 60
):
logger.debug('Refreshing the shared chromecast info list')
- BaseChromecast.ccasts, BaseChromecast.browser = pychromecast.get_chromecasts()
+ if BaseChromecast.browser is not None:
+ BaseChromecast.browser.stop_discovery()
+ BaseChromecast.ccasts, BaseChromecast.browser = pychromecast.get_chromecasts(
+ timeout=10.0
+ )
atexit.register(BaseChromecast.browser.stop_discovery)
BaseChromecast.refresh_ts = now
atexit.register(BaseChromecast.browser.stop_discovery)
BaseChromecast.refresh_ts = now
@@
-38,8
+41,7
@@
class BaseChromecast(dev.Device):
if cc.cast_info.host == ip:
logger.debug(f'Found chromecast at {ip}: {cc}')
self.cast = cc
if cc.cast_info.host == ip:
logger.debug(f'Found chromecast at {ip}: {cc}')
self.cast = cc
- self.cast.wait()
- time.sleep(0.1)
+ self.cast.wait(timeout=1.0)
if self.cast is None:
raise Exception(f'Can\'t find ccast device at {ip}, is that really a ccast device?')
if self.cast is None:
raise Exception(f'Can\'t find ccast device at {ip}, is that really a ccast device?')