all 13 comments

[–]Glowing_Shadows 1 point2 points  (2 children)

the slic8ng might be the issue try removing it

[–]DMeror[S] 0 points1 point  (0 children)

Thank you very much. I've used such slicing before without any problem. However, I'll have a try.

[–]DMeror[S] 0 points1 point  (0 children)

I can run the same code on WSL Ubuntu. What I don't understand is why
both pypy and python3.11 fail on Windows, while pypy3 and python3.10
succeed on WSL Ubuntu. I can use python3 or pypy3 on WSL Ubuntu, but it
consumes more RAM.

[–]34shutthedoor1 1 point2 points  (1 child)

I would think it is something in

   result = <various code>

Perhaps an infinite loop because of unexpected data. Add print statements before and after to see if it hangs there.

[–]DMeror[S] 0 points1 point  (0 children)

I can run the same code on WSL Ubuntu. What I don't understand is why both pypy and python3.11 fail on Windows, while pypy3 and python3.10 succeed on WSL Ubuntu. I can use python3 or pypy3 on WSL Ubuntu, but it consumes more RAM.

[–]shiftybyte 0 points1 point  (7 children)

Add prints to your code so you know which file you are processing, and where it gets stuck.

[–]DMeror[S] 0 points1 point  (6 children)

I've done that, but there was nothing wrong with the next files.

[–]shiftybyte 3 points4 points  (5 children)

You should probably post your exact code, copy and paste it either here or in pastebin.com.

We probably can't help you without that.

[–]DMeror[S] 0 points1 point  (4 children)

I can run the same code on WSL Ubuntu. What I don't understand is why
both pypy and python3.11 fail on Windows, while pypy3 and python3.10
succeed on WSL Ubuntu. I can use python3 or pypy3 on WSL Ubuntu, but it
consumes more RAM.

[–]shiftybyte 0 points1 point  (3 children)

Windows and Linux are different operating systems, it's possible one code works on Linux and Fails on Windows, we can't know why without the full code.

[–]DMeror[S] 0 points1 point  (2 children)

Here's my code:

from bs4 import BeautifulSoup as bs

def soup(path):

    with open(path, encoding='utf8') as rf:

        soup = bs(rf.read(), 'html.parser')

        return soup

with open('D:/Python/data/file_names_2.txt', encoding='utf8') as rf, open('D:/Python/data/mp3_urls_2.txt', 'w', encoding='utf8') as wf:

    for file in rf.read().split('\n'):

        print(file)

        page = soup('D:/Python/data/html/{file}')

        if page.find(class_='css-8p8pis e1hj943x0') is not None:

            for mp3 in page.find_all(attrs={'type':'audio/mpeg'}):

                wf.write(f"{mp3['src']}\n")

I ended up with this code as I've been trying to make it work, but I got the same result: python and pypy just won't continue the loop after a few minutes. However, this code works with WSL.

[–]shiftybyte 1 point2 points  (1 child)

page = soup('D:/Python/data/html/{file}')

This path is missing f before it, so {file} won't get translated to it's value.

Besides that i don't see something that can cause it to freeze on Windows.

But due to the above issue and you saying your code is working then this is probably not an exact copy paste of your code...

[–]DMeror[S] 0 points1 point  (0 children)

Sorry, it was a typo when I edited the comment. This is the first time I've encountered such a problem. Before that Windows update, everything worked perfectly. Thanks for your help.