[GH-ISSUE #482] Asciinema hangs when pty is not available #272

Closed
opened 2026-02-25 20:33:13 +03:00 by kerem · 4 comments
Owner

Originally created by @DavidVentura on GitHub (Mar 30, 2022).
Original GitHub issue: https://github.com/asciinema/asciinema/issues/482

Hi

I'm running asciinema as a subprocess in CI to record some commands. Something like subprocess.Popen(['asciinema', ...]). This works great in any local machine, but hangs in CI, without even spawning the process to record.

I've fixed it by passing a new pty for the process:

import pty
master, _ = pty.openpty()
subprocess.Popen(cmd, stdin=master, stdout=master)

but I believe asciinema could detect this and automatically spawn a new pty

Originally created by @DavidVentura on GitHub (Mar 30, 2022). Original GitHub issue: https://github.com/asciinema/asciinema/issues/482 Hi I'm running asciinema as a subprocess in CI to record some commands. Something like `subprocess.Popen(['asciinema', ...])`. This works great in any local machine, but hangs in CI, without even spawning the process to record. I've fixed it by passing a new pty for the process: ``` import pty master, _ = pty.openpty() subprocess.Popen(cmd, stdin=master, stdout=master) ``` but I believe asciinema could detect this and automatically spawn a new pty
kerem closed this issue 2026-02-25 20:33:13 +03:00
Author
Owner

@DavidVentura commented on GitHub (Mar 30, 2022):

as a note for anyone with similar issues -- you also need to set the size of the pty:

def _make_pty():               
    master, _ = pty.openpty()
    our_winsz = struct.pack("HHHH", 40, 85, 0, 0)
    fcntl.ioctl(master, termios.TIOCSWINSZ, our_winsz)
    return master
<!-- gh-comment-id:1083551804 --> @DavidVentura commented on GitHub (Mar 30, 2022): as a note for anyone with similar issues -- you also need to set the size of the pty: ```python def _make_pty(): master, _ = pty.openpty() our_winsz = struct.pack("HHHH", 40, 85, 0, 0) fcntl.ioctl(master, termios.TIOCSWINSZ, our_winsz) return master ```
Author
Owner

@ku1ik commented on GitHub (Mar 30, 2022):

Can you try the latest code from develop branch? There's a chance that recent changes there improved this.

<!-- gh-comment-id:1083696607 --> @ku1ik commented on GitHub (Mar 30, 2022): Can you try the latest code from develop branch? There's a chance that recent changes there improved this.
Author
Owner

@ku1ik commented on GitHub (May 11, 2022):

Could you test this on the latest v2.2.0?

<!-- gh-comment-id:1124302792 --> @ku1ik commented on GitHub (May 11, 2022): Could you test this on the latest v2.2.0?
Author
Owner

@DavidVentura commented on GitHub (May 24, 2022):

Works great!

<!-- gh-comment-id:1135647809 --> @DavidVentura commented on GitHub (May 24, 2022): Works great!
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/asciinema#272
No description provided.