Hi, thanks for your ideas ...

I know that's what the readable fileevent should be doing for me, that's what's so frustrating! The problem seems to be that fileevent thinks the filehandle is readable as soon as the http request starts in the child, when there is nothing to read in the filehandle and may not be for some time, which then causes <>, sysread, whatever to pause. (Incidentally, it's not a case of the Child pausing all execution in the Parent - if I stop trying to read the filehandle (or try using IO::Select - see below) then the Parent is unblocked and fine) And then the filehandle doesn't become readable again, according to fileevent (so I can't even just ignore the first readable call! Although I'd really hate doing messy stuff like that anyway ....)

I've already looked at the Mastering Perl/Tk section - the problem being that the author does not really have a solution: nothing he tries works on Win32, except using a third party module - and I'm specifically trying to avoid using any third party modules here. I actually think this is in some ways a neater solution anyway - setting up a dedicated child to grab http content, as opposed to forking every time you need to get data ... and it so almost works!!

I also tried using IO::Select, but without much success - when I tied it in with fileevent (when fileevent thought that the filehandle was readable) I couldn't get it to ever report that the filehandle had readable data (I don't know why! I had it in an infinite loop within the fileevent call, broken only when it reads data, but it never claimed it could read anything) Maybe I'll give that another try ... I guess I could try ignoring fileevent and waitvariable entirely, and rely on IO::Select to do the work ... perhaps that's the best way forwards.

Actually, I've just read a bit more and I now think what I need to do is make the filehandle non-blocking using fcntl (see the Tk::fileevent manpage) - activestate claims to have the fcntl module in their activeperl distro, so when I get to work I'll give that a try ...


In reply to Re: Re: Forking Win32 ... by owenjm
in thread Forking Win32 ... by owenjm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.