nathom / streamrip

A scriptable music downloader for Qobuz, Tidal, SoundCloud, and Deezer
GNU General Public License v3.0
2.6k stars 225 forks source link

Disable aiohttp client timeout #689

Closed wvffle closed 4 months ago

wvffle commented 4 months ago

A fix for RuntimeWarning: coroutine 'Artist._download_async.<locals>._rip' was never awaited error message

Potentially fixes: https://github.com/nathom/streamrip/issues/555, https://github.com/nathom/streamrip/issues/580, https://github.com/nathom/streamrip/issues/645

mortalis13 commented 4 months ago

Possibly for #672? The error at the end of debug log is similar

wvffle commented 4 months ago

Important thing to note: This needs further testing. I've successfully downloaded files that took over 5 minutes (default aiohttp client timeout). However, when testing with some artist, after some time, it still crashed with the same error message

mortalis13 commented 4 months ago

Those issues are different I think, and the coroutine was never awaited warning is just a result of terminated script, when you press Ctrl+C it gives the same, so it terminates forcefully.

The reason should be checked in the previous messages. In #555 the log wasn't provided by the OP, the other user's log indicates the WrongGeolocation error (probably the reason for interruption).

The #580 user haven't explained the details of his problem, I'd say he pressed Ctrl+C because of not available for stream errors, which are response from the service, not a problem of the tool. Or, it could be, because of 410 error response...

645, WrongGeolocation again, and the user doesn't provide the exact command that caused error, the download command.

689, the error is TypeError: sequence item 0: expected str instance, NoneType found.

So they probably should be treated separately, and require different solutions.

mortalis13 commented 4 months ago

Could you share the debug log that you get when it crashes? Supposing you don't end it with Ctrl+C, it should give a more detailed reason.

mortalis13 commented 4 months ago

Another example, as I've run the command from #580, it terminated itself with another error

┌─────────────────────────────── Traceback (most recent call last) ────────────────────────────────┐
│ D:\Program Files\Python311\Lib\asyncio\proactor_events.py:401 in _loop_writing                   │
│                                                                                                  │
│ D:\Program Files\Python311\Lib\asyncio\windows_events.py:574 in send                             │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

The above exception was the direct cause of the following exception:

┌─────────────────────────────── Traceback (most recent call last) ────────────────────────────────┐
│ in _run_module_as_main:198                                                                       │
│ in _run_code:88                                                                                  │
│                                                                                                  │
│                                     ... 25 frames hidden ...                                     │
│                                                                                                  │
│ D:\Program Files\Python311\Lib\site-packages\aiohttp\client_reqrep.py:976 in start               │
│                                                                                                  │
│    973 │   │   │   │   # read response                                                           │
│    974 │   │   │   │   try:                                                                      │
│    975 │   │   │   │   │   protocol = self._protocol                                             │
│ >  976 │   │   │   │   │   message, payload = await protocol.read()  # type: ignore[union-attr]  │
│    977 │   │   │   │   except http.HttpProcessingError as exc:                                   │
│    978 │   │   │   │   │   raise ClientResponseError(                                            │
│    979 │   │   │   │   │   │   self.request_info,                                                │
│                                                                                                  │
│ D:\Program Files\Python311\Lib\site-packages\aiohttp\streams.py:640 in read                      │
│                                                                                                  │
│   637 │   │   │   assert not self._waiter                                                        │
│   638 │   │   │   self._waiter = self._loop.create_future()                                      │
│   639 │   │   │   try:                                                                           │
│ > 640 │   │   │   │   await self._waiter                                                         │
│   641 │   │   │   except (asyncio.CancelledError, asyncio.TimeoutError):                         │
│   642 │   │   │   │   self._waiter = None                                                        │
│   643 │   │   │   │   raise                                                                      │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
ClientOSError: [WinError 10053] An established connection was aborted by the software in your host machine
sys:1: RuntimeWarning: coroutine 'Artist._download_async.<locals>._rip' was never awaited

Which I don't know where comes from, as "host machine" is my PC as I understand, and it could be another timeout, or denial by the external service...

Will check with full debug and with the full stack trace, though don't know how to show it yet )

mortalis13 commented 4 months ago

btw, it would be more useful to have a test reproducing/simulating the problem I'm not strong in async python, but will try to make one to see if there's some timeout that can be simulated for async tasks maybe... or directly rising an exception from one of the tickets.

nathom commented 4 months ago

As @mortalis13 said, this is caused by uncaught exceptions, which terminates the program without resolving the coroutines in the event loop. It's not an error, just a message to notify the dev in case a coroutine was created but never resolved. Changing the client timeout won't change anything.

The message is just an indicator that there is another error.