pychromecast icon indicating copy to clipboard operation
pychromecast copied to clipboard

UnboundLocalError: local variable 'host' referenced before assignment

Open elibroftw opened this issue 2 years ago • 1 comments

cast_info = cast_browser.devices[new_uuid]
new_device = pychromecast.get_chromecast_from_cast_info(cast_info, zconf)

Quick calls to pychromecast.get_chromecast_from_cast_info(cast_info, zconf) results in this error. The value of cast_info.services was set() before the error. Therefore, there is a race condition however services is set. I believe time caching would solve this problem, which is what I'll do in a wrapper for now.

  File "C:\Users\maste\Documents\GitHub\music-caster\src\music_caster.py", line 1211, in change_device
    new_device = pychromecast.get_chromecast_from_cast_info(cast_info, zconf)
  File "C:\Users\maste\AppData\Roaming\Python\Python310\site-packages\pychromecast\__init__.py", line 69, in get_chromecast_from_cast_info
    return Chromecast(
  File "C:\Users\maste\AppData\Roaming\Python\Python310\site-packages\pychromecast\__init__.py", line 272, in __init__
    cast_info = get_cast_type(cast_info, zconf)
  File "C:\Users\maste\AppData\Roaming\Python\Python310\site-packages\pychromecast\dial.py", line 121, in get_cast_type
    status = _get_status(
  File "C:\Users\maste\AppData\Roaming\Python\Python310\site-packages\pychromecast\dial.py", line 86, in _get_status
    url = FORMAT_BASE_URL_HTTPS.format(host) + path
UnboundLocalError: local variable 'host' referenced before assignment

elibroftw avatar Mar 05 '22 23:03 elibroftw

Should I be creating the Chromecast object in the Listener instead? I think I wasn't doing that because I was encountering some other error that way!

elibroftw avatar Mar 05 '22 23:03 elibroftw