Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crashes on start - Ubuntu 20.10 - errors with zeroconf and traceback error in cast.py #355

Open
RichardODonoghue opened this issue Feb 24, 2021 · 4 comments

Comments

@RichardODonoghue
Copy link

RichardODonoghue commented Feb 24, 2021

richard@SurfaceGo2:~$` sudo mkchromecast
Mkchromecast v0.3.8.1
Creating Pulseaudio Sink...
Open Pavucontrol and Select the Mkchromecast Sink.
Starting Local Streaming Server
[Done]
Selected backend: parec
Selected audio codec: mp3
Default bitrate used: 192k
Default sample rate used: 44100Hz.
 * Serving Flask app "mkchromecast.audio" (lazy loading)
PID of main process: 45213
 * Environment: production
PID of streaming process: 45219
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
Exception in thread zeroconf-Engine:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
    self.run()
  File "/usr/lib/python3/dist-packages/zeroconf/__init__.py", line 1228, in run
    reader.handle_read(socket_)
  File "/usr/lib/python3/dist-packages/zeroconf/__init__.py", line 1301, in handle_read
    self.zc.handle_response(msg)
  File "/usr/lib/python3/dist-packages/zeroconf/__init__.py", line 2501, in handle_response
    with self._handlers_lock:
AttributeError: 'Zeroconf' object has no attribute '_handlers_lock'
Traceback (most recent call last):
  File "/usr/share/mkchromecast/mkchromecast/cast.py", line 113, in _get_chromecasts
    return list(pychromecast.get_chromecasts_as_dict().keys())
AttributeError: module 'pychromecast' has no attribute 'get_chromecasts_as_dict'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/mkchromecast", line 283, in <module>
    mk()
  File "/usr/bin/mkchromecast", line 53, in __init__
    self.audio_linux()
  File "/usr/bin/mkchromecast", line 72, in audio_linux
    self.cc.initialize_cast()
  File "/usr/share/mkchromecast/mkchromecast/cast.py", line 135, in initialize_cast
    self.cclist = self._get_chromecasts()
  File "/usr/share/mkchromecast/mkchromecast/cast.py", line 115, in _get_chromecasts
    self._chromecasts_by_name = {c.name: c for c in
  File "/usr/share/mkchromecast/mkchromecast/cast.py", line 115, in <dictcomp>
    self._chromecasts_by_name = {c.name: c for c in
AttributeError: 'list' object has no attribute 'name'

@RichardODonoghue RichardODonoghue changed the title crashes on start - Ubuntu 20.10 - Exception in thread zeroconf-Engine. crashes on start - Ubuntu 20.10 - errors with zeroconf and traceback error in cast.py Feb 24, 2021
@RichardODonoghue
Copy link
Author

Update:

I managed to fix the zeroconf errors by updating zeroconf in PIP.

Now I just have the second error left

@ebrahimradi
Copy link

I faced this issue also:

`$ mkchromecast
Mkchromecast v0.3.8.1
Creating Pulseaudio Sink...
Open Pavucontrol and Select the Mkchromecast Sink.
Starting Local Streaming Server
[Done]
Selected backend: parec
Selected audio codec: mp3
Default bitrate used: 192k
Default sample rate used: 44100Hz.
PID of main process: 4468

  • Serving Flask app "mkchromecast.audio" (lazy loading)
  • Environment: production
    PID of streaming process: 4606
    WARNING: This is a development server. Do not use it in a production deployment.
    Use a production WSGI server instead.
  • Debug mode: off
  • Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
    Traceback (most recent call last):
    File "/usr/share/mkchromecast/mkchromecast/cast.py", line 113, in _get_chromecasts
    return list(pychromecast.get_chromecasts_as_dict().keys())
    AttributeError: module 'pychromecast' has no attribute 'get_chromecasts_as_dict'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/mkchromecast", line 283, in
mk()
File "/usr/bin/mkchromecast", line 53, in init
self.audio_linux()
File "/usr/bin/mkchromecast", line 72, in audio_linux
self.cc.initialize_cast()
File "/usr/share/mkchromecast/mkchromecast/cast.py", line 135, in initialize_cast
self.cclist = self._get_chromecasts()
File "/usr/share/mkchromecast/mkchromecast/cast.py", line 115, in _get_chromecasts
self._chromecasts_by_name = {c.name: c for c in
File "/usr/share/mkchromecast/mkchromecast/cast.py", line 115, in
self._chromecasts_by_name = {c.name: c for c in
AttributeError: 'list' object has no attribute 'name'`

@ebrahimradi
Copy link

more debug info!

mkchromecast --debug
ALSA device name: None.
Google Cast name: None.
backends:  ['ffmpeg', 'avconv', 'parec', 'gstreamer']
ALSA device name: None.
Google Cast name: None.
backends:  ['ffmpeg', 'avconv', 'parec', 'gstreamer']
USER =ebrahim
PATH =/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Mkchromecast v0.3.8.1
:::cast::: sockets method 192.168.1.239
Creating Pulseaudio Sink...
Open Pavucontrol and Select the Mkchromecast Sink.
Starting Local Streaming Server
[Done]
:::audio::: chunk_size, frame_size, buffer_size: 64, 2048, 8192
Selected backend: parec
Selected audio codec: mp3
Default bitrate used: 192k
Default sample rate used: 44100Hz.
:::audio::: command ['lame', '-b', '192', '-r', '-']
 * Serving Flask app "mkchromecast.audio" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
PID of main process: 4928
PID of streaming process: 4936
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
Traceback (most recent call last):
  File "/usr/share/mkchromecast/mkchromecast/cast.py", line 113, in _get_chromecasts
    return list(pychromecast.get_chromecasts_as_dict().keys())
AttributeError: module 'pychromecast' has no attribute 'get_chromecasts_as_dict'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/mkchromecast", line 283, in <module>
    mk()
  File "/usr/bin/mkchromecast", line 53, in __init__
    self.audio_linux()
  File "/usr/bin/mkchromecast", line 72, in audio_linux
    self.cc.initialize_cast()
  File "/usr/share/mkchromecast/mkchromecast/cast.py", line 135, in initialize_cast
    self.cclist = self._get_chromecasts()
  File "/usr/share/mkchromecast/mkchromecast/cast.py", line 115, in _get_chromecasts
    self._chromecasts_by_name = {c.name: c for c in
  File "/usr/share/mkchromecast/mkchromecast/cast.py", line 115, in <dictcomp>
    self._chromecasts_by_name = {c.name: c for c in
AttributeError: 'list' object has no attribute 'name'

@nilsdeppe
Copy link

nilsdeppe commented Feb 28, 2021

This is because of an upstream change in pychromecast:
home-assistant-libs/pychromecast@d76c8f1
merged as part of:
home-assistant-libs/pychromecast#385

Edit: this appears to be resolved if you clone the git repo itself rather than using apt to install mkchromecast

This changes the return type of get_chromecasts to a tuple(list, browser) while previously it was just a list. I'm not a python expert so I can't suggest the "best" way to fix, but one workaround is:

    def _get_chromecasts(self):
        # compatibility
        try:
            return list(pychromecast.get_chromecasts_as_dict().keys())
        except AttributeError:
            available_chromecasts = pychromecast.get_chromecasts(
                                             tries=self.tries)
            self._chromecasts_by_name = {c.name: c for c in
                                         (available_chromecasts[0] if
                                         type(available_chromecasts) == tuple
                                          else available_chromecasts)}
            
            return list(self._chromecasts_by_name.keys())

though, it's probably cleaner to check the pychromecast version and make decisions based on that.

Now, there seem to be a few other issues that arise with pychromecast 9.0.0 (or maybe earlier versions, I haven't experimented extensively), where the Chromecast.host object is set to None. I don't know how much of an issue this is, but at face value commenting out:

        # try:
        #     print(colors.options('The IP of ') +
        #           colors.success(self.cast_to) + colors.options(' is:') +
        #           ' ' + self.cast.host)
        # except TypeError:
        #     print(colors.options('The IP of ') +
        #           colors.success(self.cast_to.player_name) +
        #           colors.options(' is:') + ' ' + self.cast_to.ip_address)
        # except AttributeError:
        #     for _ in self.sonos_list:
        #         if self.cast_to in _.player_name:
        #             self.cast_to = _
        #     print(colors.options('The IP of ') +
        #           colors.success(self.cast_to.player_name) +
        #           colors.options(' is:') + ' ' + self.cast_to.ip_address)

at roughly line 312 gets me to the "casting" part, though nothing is actually showing on my chromecast...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants