postlund / pyatv

A client library for Apple TV and AirPlay devices
https://pyatv.dev
MIT License
838 stars 91 forks source link

Python 3.11 / 3.12 atvscript push_updates throwing errors #2268

Closed maxileith closed 8 months ago

maxileith commented 8 months ago

Describe the bug

Hello everybody,

I want to utilize the atvscript push_updates for a project of mine. I have noticed, that atvscript push_updates does not work when using Python 3.11 or 3.12. With Python 3.10 everything works just fine. I have attached the logs below. atvremote push_updates does run without any errors.

Error log

❯ atvscript -s 42.42.42.42 push_updates --companion-credentials xxxx --airplay-credentials xxxx
{"result": "success", "datetime": "2023-10-25T16:46:33.635718+02:00", "power_state": "on"}
{"result": "success", "datetime": "2023-10-25T16:46:33.635767+02:00", "output_devices": [{"name": "Wohnzimmer (2)", "identifier": "82091D04-8D8E-4CF8-8FAA-4B7FC9979EB9"}]}
{"result": "success", "datetime": "2023-10-25T16:46:33.636150+02:00", "hash": "ca496c14642c78af6dd4250191fe175f6dafd72b4c33bcbab43c454aae051da1", "media_type": "unknown", "device_state": "idle", "title": null, "artist": null, "album": null, "genre": null, "total_time": null, "position": null, "shuffle": "off", "repeat": "off", "series_name": null, "season_number": null, "episode_number": null, "content_identifier": null, "app": null, "app_id": null}
{"result": "failure", "datetime": "2023-10-25T16:46:33.636294+02:00", "exception": "Passing coroutines is forbidden, use tasks explicitly.", "stacktrace": "Traceback (most recent call last):\n  File \"/home/maxileith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/pyatv/scripts/atvscript.py\", line 389, in appstart\n    args.output(await _handle_command(args, abort_sem, storage, loop)),\n                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/home/maxileith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/pyatv/scripts/atvscript.py\", line 271, in _handle_command\n    return await _run_command(atv, args, abort_sem, loop)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/home/maxileith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/pyatv/scripts/atvscript.py\", line 305, in _run_command\n    await wait_for_input(loop, abort_sem)\n  File \"/home/maxileith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/pyatv/scripts/atvscript.py\", line 167, in wait_for_input\n    await asyncio.wait(\n  File \"/home/maxileith/.pyenv/versions/3.11.6/lib/python3.11/asyncio/tasks.py\", line 425, in wait\n    raise TypeError(\"Passing coroutines is forbidden, use tasks explicitly.\")\nTypeError: Passing coroutines is forbidden, use tasks explicitly.\n"}
/home/maxileith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/pyatv/scripts/atvscript.py:393: RuntimeWarning: coroutine 'Semaphore.acquire' was never awaited
  print(args.output(output(False, exception=ex)), flush=True)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
/home/maxileith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/pyatv/scripts/atvscript.py:393: RuntimeWarning: coroutine 'StreamReader.readline' was never awaited
  print(args.output(output(False, exception=ex)), flush=True)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

How to reproduce the bug?

What is expected behavior?

It works, like it does with Python 3.10

Operating System

Linux

Python

Other

pyatv

0.14.3

Device

Apple TV 4k (3rd Gen.) TvOS 17.0

Additional context

I think everything is said.

maxileith commented 8 months ago

I just tried it with the official docker container and unfortunately it did not work either.

postlund commented 8 months ago

Yeah, I'm probably doing something stupid here. I will have a look when I have a few moments over. Thanks for reporting!