Coruscate has asked for the wisdom of the Perl Monks concerning the following question:

As of yet, this is my first gripe with POE (or more specifically, POE::Wheel::ReadWrite (not sure which is to blame). Within the server, I need to grab pages from the net. Some of these pages may take quite a number of seconds to retrieve, so I wish to let the user know that it is grabbing the page and that it might take a few seconds. So I programmed the following lines of code, thinking it might just DWIM:

$heap->{wheel}->put("Grabbing webpage. May take a moment..."); my $ua = new LWP::UserAgent; my $html = $ua->get($url_to_retrieve);

But of course not! It would make things way too easy for put() to _immediately_ send out the message. So of course, put() places the message in a queue and unfortunately for me, it's not sent out until after the webpage retrieval is complete. Definitely not what I wanted to happen.

I've tried playing with POE::Kernel's delay(), yield() and call() methods, with no working results. If anyone happens to know of some code to help me (or better yet, point me to some docs that I overlooked) I'd be very happy :)


If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.

Replies are listed 'Best First'.
Re: POE's queue and Wheel::ReadWrite->put()
by Matts (Deacon) on Jul 16, 2003 at 22:32 UTC
    You need to use something that uses non-blocking IO using the POE internals. While LWP::UserAgent uses non-blocking IO, it uses select() internally rather than letting the POE kernel do the work. Try using POE::Component::HTTP::Client instead, which does exactly what you want.
Re: POE's queue and Wheel::ReadWrite->put()
by PodMaster (Abbot) on Jul 16, 2003 at 21:15 UTC
    The get is blocking. See LWP HEAD Replacement for an example of what the get method is capable of, or just read the fine manual (you can do user status updates from the callback).

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.