[GH-ISSUE #1269] Bug: print causes the io error 9: Bad file descriptor when exporting static html #781

Open
opened 2026-03-01 14:46:15 +03:00 by kerem · 2 comments
Owner

Originally created by @sasasqt on GitHub (Nov 10, 2023).
Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/1269

Describe the bug

these commands

/home/user/.local/bin/archivebox list --html > /home/user/archivebox/index.html
/home/user/.local/bin/archivebox list --html

throw an error

print(output)

OSError: [Errno 9] Bad file descriptor

github.com/ArchiveBox/ArchiveBox@f5739506f6/archivebox/main.py (L883C4-L883C4)


I changed print(output) to

        with open('/home/user/archivebox/index.html','w') as file:
            file.write(output)

and the problem was resolved. i guess import sys; sys.stdout = open('stdout.txt', 'w') would also work.


i suspected that the stdout pipe got filled up causing the error and i can not reliably reproduce this error


std flush before print also seems to mitigate this problem


Env:
my archivebox is on a low budget vps, and the archive folder is actually remote mounted google drive folder.

Steps to reproduce

Screenshots or log output

ArchiveBox version

replace this line with the *full*, unshortened output of running `archivebox version`
Originally created by @sasasqt on GitHub (Nov 10, 2023). Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/1269 <!-- Please fill out the following information, feel free to delete sections if they're not applicable or if long issue templates annoy you. (the only required section is the version information) --> #### Describe the bug <!-- A description of what the bug is, what you expected to happen, and any relevant context about issue. --> these commands ``` /home/user/.local/bin/archivebox list --html > /home/user/archivebox/index.html /home/user/.local/bin/archivebox list --html ``` throw an error > print(output) > OSError: [Errno 9] Bad file descriptor > https://github.com/ArchiveBox/ArchiveBox/blob/f5739506f637734fa194b9bf7c54f01b1333b5a2/archivebox/main.py#L883C4-L883C4 --- I changed ``print(output)`` to ``` with open('/home/user/archivebox/index.html','w') as file: file.write(output) ``` and the problem was resolved. i guess ``import sys; sys.stdout = open('stdout.txt', 'w')`` would also work. --- i suspected that the stdout pipe got filled up causing the error and i can not reliably reproduce this error --- std flush before print also seems to mitigate this problem --- Env: my archivebox is on a low budget vps, and the archive folder is actually remote mounted google drive folder. #### Steps to reproduce <!-- For example: 1. Ran ArchiveBox with the following config '...' 2. Saw this output during archiving '....' 3. UI didn't show the thing I was expecting '....' --> #### Screenshots or log output <!-- If applicable, post any relevant screenshots or copy/pasted terminal output from ArchiveBox. If you're reporting a parsing / importing error, **you must paste a copy of your redacted import file here**. --> #### ArchiveBox version <!-- Run the `archivebox version` command locally then copy paste the result here: --> ```logs replace this line with the *full*, unshortened output of running `archivebox version` ``` <!-- Tickets without full version info will closed until it is provided, we need the full output here to help you solve your issue -->
Author
Owner

@sasasqt commented on GitHub (Nov 10, 2023):

btw how to specify the latest snapshot first in --sort when outputing static html? --sort=timestamp does the opposite

<!-- gh-comment-id:1806352356 --> @sasasqt commented on GitHub (Nov 10, 2023): btw how to specify the latest snapshot first in ``--sort`` when outputing static html? ``--sort=timestamp`` does the opposite
Author
Owner

@pirate commented on GitHub (Nov 14, 2023):

I need the output of archivebox version to help, please edit your post and add it.

btw how to specify the latest snapshot first in --sort when outputing static html? --sort=timestamp does the opposite

use --sort=-timestamp

<!-- gh-comment-id:1809544274 --> @pirate commented on GitHub (Nov 14, 2023): I need the output of `archivebox version` to help, please edit your post and add it. > btw how to specify the latest snapshot first in --sort when outputing static html? --sort=timestamp does the opposite use `--sort=-timestamp`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ArchiveBox#781
No description provided.