beedaddy/radiorec

Cannot open m3u urls -> ValueError: I/O operation on closed file.

gjelsas opened this issue · 6 comments

I'm currently getting ValueError: I/O operation on closed file. when trying to record stations with m3u urls. With mp3-urls it works though.

It seems to be the code around line 126 where the Poolmanager requests the m3u url, and an empty value is stored in the value line in line 127.

I'm using mp3 urls right now, but this could be fixed easily I guess...

@gjelsas do you have an example m3u file with which the issue occured?

It occured even on the urls provided by the sample configuration!

Hi @gjelsas , thanks for your feedback and a bit more of informations.

Hmm, strange, maybe mine where resolved differently? I don't see a reason why that would be the case... I'm currently using radiorec on Ubuntu 20.04...
When debugging radiorec, the streamurl variable was empty and therefore throwing the exception described in the title if the corresponding issue...
Could this be a dependency issue for me?

Tested now with an upgraded version of python using python 3.8.6 and urllib3 1.25.11. There i'm able to reproduce your initial issue. For me it seems, the issue is already directly within with pool.request('GET',streamurl) as remotefile:.

And here, the issue is described: urllib3/urllib3#1660

Need to switch to use contextlib. On the other side, we shall consider to rework that part in order to handle some issues properly (e.g. 404 errors, timeouts, etc.) by not using with, but working with the result, checking status, catching MaxRetryError. Proper assigning and declaration of tmpstr and checking if we could correctly interpret file.

May you get it a try?

#16 (comment)
I hope this fix does it for this problem. If you could check this pr?
Greetings

@monofox @beedaddy Is that now fixing the issue? Maybe you could integrate my pull request then...

Thank's, @gjelsas! PR is merged. If there are still problems, we can re-open the issue.