mirror of
https://github.com/stevenrobertson/cuburn.git
synced 2025-02-05 11:40:04 -05:00
Non-blocking poll for encoder subprocess
This commit is contained in:
parent
8736608abc
commit
7a2b9983f1
@ -16,6 +16,11 @@ if not hasattr(scipy.misc, 'toimage'):
|
|||||||
raise ImportError("Could not find scipy.misc.toimage. "
|
raise ImportError("Could not find scipy.misc.toimage. "
|
||||||
"Are scipy and PIL installed?")
|
"Are scipy and PIL installed?")
|
||||||
|
|
||||||
|
try:
|
||||||
|
import gevent
|
||||||
|
except ImportError:
|
||||||
|
gevent = None
|
||||||
|
|
||||||
def launchC(name, mod, stream, dim, fb, *args):
|
def launchC(name, mod, stream, dim, fb, *args):
|
||||||
launch(name, mod, stream,
|
launch(name, mod, stream,
|
||||||
(32, 8, 1), (int(np.ceil(dim.w/32.)), int(np.ceil(dim.h/8.))),
|
(32, 8, 1), (int(np.ceil(dim.w/32.)), int(np.ceil(dim.h/8.))),
|
||||||
@ -168,10 +173,20 @@ class X264Output(Output, ClsMod):
|
|||||||
self.zeros.fill(32767)
|
self.zeros.fill(32767)
|
||||||
|
|
||||||
def _flush_sub(self, subp):
|
def _flush_sub(self, subp):
|
||||||
(stdout, stderr) = subp.communicate()
|
if gevent is not None:
|
||||||
|
# Use non-blocking poll to allow applications to continue
|
||||||
|
# rendering in other coros
|
||||||
|
subp.stdin.close()
|
||||||
|
log = ''
|
||||||
|
while subp.poll() is None:
|
||||||
|
log += subp.stderr.read()
|
||||||
|
gevent.sleep(0.1)
|
||||||
|
log += subp.stderr.read()
|
||||||
|
else:
|
||||||
|
(stdout, log) = subp.communicate()
|
||||||
if subp.returncode:
|
if subp.returncode:
|
||||||
raise IOError("x264 exited with an error")
|
raise IOError("x264 exited with an error")
|
||||||
return stderr
|
return log
|
||||||
|
|
||||||
def _flush(self):
|
def _flush(self):
|
||||||
if self.subp is None:
|
if self.subp is None:
|
||||||
@ -185,7 +200,7 @@ class X264Output(Output, ClsMod):
|
|||||||
self.asubp = None
|
self.asubp = None
|
||||||
return ({'_color.h264': self.outf, '_alpha.h264': self.aoutf},
|
return ({'_color.h264': self.outf, '_alpha.h264': self.aoutf},
|
||||||
[('x264_color', log), ('x264_alpha', alog)])
|
[('x264_color', log), ('x264_alpha', alog)])
|
||||||
return {'.h264': self.outf}, [('x264_color', stderr)]
|
return {'.h264': self.outf}, [('x264_color', log)]
|
||||||
|
|
||||||
def _write(self, buf, subp):
|
def _write(self, buf, subp):
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user