[mythtv-users] Tweaking the Transcode Wrapper Stub
Joseph Fry
joe at thefrys.com
Fri May 2 14:28:47 UTC 2014
On Fri, May 2, 2014 at 9:59 AM, Raymond Wagner <raymond at wagnerrp.com> wrote:
> On 5/2/2014 9:22 AM, Joseph Fry wrote:
>>
>> Thanks Raymond, and I apologize for not being more clear. Yes, I want
>> to read the output while the command is in progress.so that I can
>> update the job's progress information (as you see when you look at an
>> in progress mythtranscode job).
>>
>> From what you said above, it looks like I need to adjust this block
>> somehow to tell it to use the ._runasync() method instead of
>> ._runcmd() method... but the code doesn't explicitly call either
>> method so what do I change?:
>>
>> task = System(path=transcoder, db=db)
>> try:
>> output = task(<my avconv arguments>)
>
>
> Running task(args) will run the __call__() method, which in turn runs the
> command() method, and you're right back where you were. You need to create
> the System object, and then run _runasync() instead.
>
>>>> task = System(path=transcoder, db=db)
>>>> taskinst = task._runasync(<my avconv arguments>)
makes sense.
>
>
>
>> Also, I had looked at the Process.poll method, however I cannot figure
>> out how to use it. Is it as simple as doing something like this in my
>> try: block?
>>
>> while True:
>> output.poll()
>
>
> That does nothing. poll() returns the status of the application instance.
> -1 means it is still running (I think). 0 means it has terminated
> successfully. >0 means it has terminated with an error.
>
>
>
>> line = output.stdout.readline()
>> eline = output.stderr.readline()
>
>
> This is a simple character buffer. It has no smarts to recognize end of
> lines, so readline() is not available. If you want to read one line at a
> time, you will need to read into your own buffer, and then scan through it
> to discover individual lines, or patch the DequeBuffer class to add a
> readline() method.
Sounds like.... fun?
>
>
>> if (line == "" and eline == "" and process.returncode != None):
>> break
>
>
> returncode is populated by the _runcmd() method, populated by waiting for
> the application instance to terminate, and then querying that code using
> poll(). It will not be available if you are using _runasync() instead of
> _runcmd(). You will need to poll() the Process object directly.
Ok... I think I understand?
>
>
>> Is there a script that you are aware of that uses this that I could look
>> at?
>
>
> I don't believe I've ever used the async interface for this class.
Well I guess I get to venture into new territory. Wish me luck.
More information about the mythtv-users
mailing list