<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 21, 2017 at 11:11 PM, Stephen Worthington <span dir="ltr"><<a href="mailto:stephen_agent@jsw.gen.nz" target="_blank">stephen_agent@jsw.gen.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5">On Wed, 22 Nov 2017 06:03:31 +0000, you wrote:<br>
<br>
>Hi Everyone,<br>
><br>
>I've been working on an external recorder for a while. It works most of the<br>
>time, but recently i've been getting new errors.<br>
><br><snip><br>
>My problem below is that I am getting a "Resource temporarily unavailable<br>
>(11)" when mythtv is trying to read from the stdin (the stdout of my<br>
>program with the video stream)<br>
><br>
>This seems to happen from this call:<br>
><a href="https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythtv/recorders/ExternalStreamHandler.cpp#L125" rel="noreferrer" target="_blank">https://github.com/MythTV/<wbr>mythtv/blob/master/mythtv/<wbr>libs/libmythtv/recorders/<wbr>ExternalStreamHandler.cpp#L125</a><br>
><br>
>The STDIN stream is configured to be non blocking, so the errno 11 isn't<br>
>unexpected:<br>
><a href="https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythtv/recorders/ExternalStreamHandler.cpp#L343" rel="noreferrer" target="_blank">https://github.com/MythTV/<wbr>mythtv/blob/master/mythtv/<wbr>libs/libmythtv/recorders/<wbr>ExternalStreamHandler.cpp#L343</a><br>
><br>
>I am not sure what to change to keep this from happening.... it fails about<br>
>50% of the time, which is annoying.<br>
><br>
>I am looking for advice on a fix, or how to troubleshoot. I am running 0.29<br>
>on Ubuntu 16.04.<br>
><br>
>Thanks!<br>
>Marc<br>
><br><snip><br>
<br>
</div></div>If I am reading the ExternalStreamHandler.cpp.<wbr>ExternIO::Read function<br>
correctly, then the only way that can happen is if your stdout stream<br>
indicates that it has data buffered and available to be read (the<br>
poll() call from the Ready() call says there is data there), but then<br>
your stdout fails to provide that data when it is called from read().<br>
The most obvious reason I can think of for that would be if your code<br>
was slow in responding to the read(), due to some unforeseen<br>
circumstance such as garbage collection or being swapped out at the<br>
time. But I would have thought that your stdout buffer would have<br>
been there waiting to be read, rather than any higher code needing to<br>
be run to provide the data. Are you using buffered I/O on your<br>
stdout?<br><br></blockquote><div><br></div><div>Thanks for the quick reply Stephen. I am going to very quickly expose my ignorance on how these FDs work. (just setting expectations)</div><div><br></div><div>Yes, I am using buffered output, specifically a BufferedWriter in Python (<a href="https://docs.python.org/2/library/io.html#io.BufferedWriter">https://docs.python.org/2/library/io.html#io.BufferedWriter</a>). I added explicit "flush" commands after the 'write' command, but it didn't help.</div><div><br></div><div>I'll try dropping the buffered output tonight and see what happens. I didn't think that using a buffered writer would affect how data is present in the stream.</div><div><br></div><div>Thanks,</div><div>Marc</div><div><br></div><div><br></div><div><br></div></div></div></div>