pyatv: MRP status timeout?

In addition to home-assistant I’ve been using atvremote to monitor the status of my Apple TVs for years. This has worked fine pre-MRP (and still does, with an ATV 3). It initially works fine with an Apple TV 4 and tvOS 13.2. But after a while it stops working with an error like this:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/pyatv/__main__.py", line 488, in _run_application
    return await cli_handler(loop)
  File "/usr/local/lib/python3.5/dist-packages/pyatv/__main__.py", line 313, in cli_handler
    return await _handle_commands(args, loop)
  File "/usr/local/lib/python3.5/dist-packages/pyatv/__main__.py", line 403, in _handle_commands
    ret = await _handle_device_command(args, cmd, atv, loop)
  File "/usr/local/lib/python3.5/dist-packages/pyatv/__main__.py", line 432, in _handle_device_command
    atv.metadata, cmd, True, *cmd_args))
  File "/usr/local/lib/python3.5/dist-packages/pyatv/__main__.py", line 454, in _exec_command
    value = await tmp(*args)
  File "/usr/local/lib/python3.5/dist-packages/pyatv/mrp/__init__.py", line 246, in playing
    await self.protocol.start()
  File "/usr/local/lib/python3.5/dist-packages/pyatv/mrp/protocol.py", line 71, in start
    await self.send_and_receive(msg)
  File "/usr/local/lib/python3.5/dist-packages/pyatv/mrp/protocol.py", line 161, in send_and_receive
    return await self._receive(identifier, timeout)
  File "/usr/local/lib/python3.5/dist-packages/pyatv/mrp/protocol.py", line 170, in _receive
    semaphore.acquire(), timeout, loop=self.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 404, in wait_for
    raise futures.TimeoutError()
concurrent.futures._base.TimeoutError

The command that I’m periodically executing is:

/usr/local/bin/atvremote --id […] --device_credentials […] playing

It may be that pyatv is triggering some kind of bug/resource leak in the Apple TV itself; I’m not entirely sure how to proceed. Any ideas?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

@nriley Going through som old issues here… This is still valid I presume and I have not yet found any solution to it. However, there’s a new script called atvscript that can monitor play status and report it back to stdout as JSON. Maybe that can be interesting to you, as a replacement to polling the status? You can read about it here: https://pyatv.dev/documentation/atvscript/

I stopped using it, because of multiple issues including not being able to decode playing status. I can try later on weekend and report back.