Pyatv: Backtrace on lost connection

Created on 20 Jun 2020  路  4Comments  路  Source: postlund/pyatv

Describe the bug
When the connection is lost the atv object can be None which leads to backtrace and improper cleanup:

Error doing job: Exception in callback _SelectorSocketTransport._call_connection_lost(ConnectionRes...eset by peer'))
Traceback (most recent call last):
  File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/lib/python3.7/asyncio/selector_events.py", line 916, in _call_connection_lost
    super()._call_connection_lost(exc)
  File "/usr/lib/python3.7/asyncio/selector_events.py", line 690, in _call_connection_lost
    self._protocol.connection_lost(exc)
  File "/srv/homeassistant-3.7/lib/python3.7/site-packages/pyatv/mrp/connection.py", line 50, in connection_lost
    self.atv.listener.connection_lost(exc)
  File "/home/homeassistant/.homeassistant/custom_components/apple_tv/__init__.py", line 166, in connection_lost
    _LOGGER.warning('Connection lost to Apple TV "%s"', self.atv.name)
AttributeError: 'MrpAppleTV' object has no attribute 'name'

To Reproduce
Unknown.

Expected behavior
Don't cause exceptions.

System Setup (please complete the following information):

  • OS: Ubuntu
  • Python: 3.7.7
  • pyatv: custom component (db51ab2)

    • Apple TV: Apple TV 4th Gen

Additional context

bug

All 4 comments

Yeah, this looks utterly wrong. It's not that self.atv is None, but it has no name property. It should be fetched from the config entry instead. I will try to fix that.

Pushed an update now!

Did you manage to verify if the update solved the problem? If that's the case, feel free to close the issue!

I haven't seen the problem since, thanks for the quick fix!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

postlund picture postlund  路  7Comments

nriley picture nriley  路  18Comments

postlund picture postlund  路  13Comments

lorenzoCuevas picture lorenzoCuevas  路  10Comments

MichelRabozee picture MichelRabozee  路  12Comments