Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- YOLO
- windows forms
- SSH
- Selenium
- Numpy
- Docker
- C#
- ubuntu
- 오류
- Python
- 핑거스타일
- C
- label
- C++
- 기타 연주
- error
- 채보
- LIST
- pandas
- 컨테이너
- paramiko
- VS Code
- pip
- Visual Studio
- OpenCV
- Linux
- mysql
- 프로그래머스
- pytorch
- JSON
Archives
- Today
- Total
기계는 거짓말하지 않는다
Python subprocess pipe stdin write 중단 문제 본문
아래와 같은 예시 코드에서
import subprocess as sp
# 실행 시킬 명령어
command = ["any command..."]
proc = sp.Popen(command, stdin=sp.PIPE, stderr=sp.PIPE)
while 반복 조건:
# 큰 데이터 받음
data = 데이터 IN
# write
proc.stdin.write(data.tostring())
반복문을 실행하다가 프로세스가 종료되는 경우가 있다.
한 가지 상황은 이미지를 데이터로 받아 FFMPEG에 raw data로 넘겨줄 때였다.
FFMPEG는 stderr에 지속해서 기록하므로 버퍼가 계속 차게 된다.
stderr을 사용하지 않거나, 비워주어야 한다.
비우는 방법은 write 후 stderr을 close 하거나 read 시켜줄 수 있다.
proc.stdin.write(data.tostring())
proc.stderr.close() # 또는 proc.stderr.readline()
opencv - Python gets stuck at pipe.stdin.write(image.tostring()) - Stack Overflow
Python gets stuck at pipe.stdin.write(image.tostring())
I am reading each frame of video and adding time stamp to it as given below. command = ['ffmpeg', '-y', # (optional) overwrite output file if it exists '-f', 'rawvideo', #I...
stackoverflow.com
'Python' 카테고리의 다른 글
Comments