Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try to work around Python quirk in main.py I/O support to avoid extraneous exceptions when reading piped stdin #101

Open
tomasohara opened this issue Aug 12, 2024 · 0 comments

Comments

@tomasohara
Copy link
Owner

Due to a quirk with Python, piped stdin filtered using head can lead to exceptions when reading stdin:

Traceback (most recent call last):
  File "/var/root/Mezcla/mezcla/convert_emoticons.py", line 157, in <module>
    main()
  File "/var/root/Mezcla/mezcla/convert_emoticons.py", line 150, in main
    print(ce.convert(line))
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe

via convert_emoticons.py:

    for line in main_app.read_entire_input().splitlines():
        print(ce.convert(line))
    return

It would be good to add a workaround to main to avoid head scratching about client scripts.

See https://stackoverflow.com/questions/26692284/how-to-prevent-brokenpipeerror-when-doing-a-flush-in-python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant