Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

POE::Component::Server::HTTP: The _signal event is deprecated

by ls (Scribe)
on Dec 15, 2002 at 13:00 UTC ( [id://219990]=perlquestion: print w/replies, xml ) Need Help??

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

Hello,

I just try to change some code from HTTP::Daemon to POE with POE::Component::Server::HTTP and get the following warning:

The _signal event is deprecated. Please use sig() to register a signa +l handler at E:\work\projects\cws_poe\cws.pl line 12 POE::Kernel's run() method was never called.
I've searched the documentation comming with POE and the monastir as well as http://poe.perl.org/, but haven't yet found out how I can change this and what can I register as a signal with POE.

Please, could you tell me what I have to do?

Best regards,

ls

The code of the Script is nearly exactly the code from perldoc POE::Component::Server::HTTP:

#! /usr/bin/perl use warnings; use strict; use POE; use POE::Component::Server::HTTP; use HTTP::Status; use vars qw($Port); $Port = 8889; my $httpd = POE::Component::Server::HTTP->new ( Port => $Port, ContentHandler => { '/' => \&MainHandler }, Headers => {Server => 'any server' }, ); POE::Kernel->call($httpd, "shutdown"); sub MainHandler { my ($request, $response) = @_; $response->code(RC_OK); $response->content("Hi, you fetched ". $request->uri); return RC_OK; } # MainHandler

Replies are listed 'Best First'.
Re: POE::Component::Server::HTTP: The _signal event is deprecated
by Matts (Deacon) on Dec 15, 2002 at 16:18 UTC
    There's a couple of things wrong here. The main one being that you're not actually starting the kernel (admittedly PoCo::Server::HTTPD's docs are lacking a bit in this respect). What you need to do is create a session and then start the kernel:
    POE::Session->create( inline_states => { _start => \&create_httpd, _stop => \&stop_httpd, }, args => [8080], ); $poe_kernel->run; sub create_httpd { my ($kernel, $heap, $Port) = @_[KERNEL, HEAP, ARG0]; $kernel->alias_set('httpd_parent'); my $httpd = POE::Component::Server::HTTP->new ( Port => $Port, ContentHandler => { '/' => \&MainHandler }, Headers => {Server => 'any server' }, ); $heap->{httpd} = $httpd; } sub stop_httpd { my ($kernel, $heap) = @_[KERNEL, HEAP]; $kernel->call($heap->{httpd}, 'shutdown'); } sub MainHandler { my ($request, $response) = @_; $response->code(RC_OK); $response->content("Hi, you fetched ". $request->uri); return RC_OK; } # MainHandler
    The other thing wrong is a bug in PoCo::Server::HTTP - it uses the deprecated _signal event, but luckily for you it simply sets it to an empty sub, so you can comment that line out (just grep for _signal in the HTTP.pm file in the distro). (Note: I haven't tested the above code, so it might not work. But it should).
Re: POE::Component::Server::HTTP: The _signal event is deprecated
by dingus (Friar) on Dec 15, 2002 at 15:59 UTC
    I'd recommend subscribing to and asking on the POE mailing list - as most POE knowledge seems to reside there

    Dingus


    Enter any 47-digit prime number to continue.
Re: POE::Component::Server::HTTP: The _signal event is deprecated
by pg (Canon) on Dec 15, 2002 at 16:31 UTC
    sig() is not defined in the immediate class you used, but defined in POE::Kernel. What you need to do is to first create a POE::Kernel object, say $kernel, then:
    $kernel->sig($signal_name, $state_name);
    Give a try.

    But I do think POE should provide better and more clear documentation, at least say something like "please see POE::Kernel for details about how to use sig()", if they don't want people to reconsider :-) especially when standard Perl distribution itself is getting better.
      This is incredibly misinformed. Do not, as this poster suggests, reconsider using POE.

      It's pretty well accepted that Perl 6 is at least another year away, and for widespread use I would expect it to be 2 or 3 years away (think about all the modules that will probably need porting). That's a long time to wait for a new programming language to be widely usable. I'm not suggesting that Perl 6 isn't going to be chock full of good ideas, but it's not here yet, and until it is a regular day-to-day coder simply can't consider it as an alternative option.

      Secondly, yes Perl 5.8 supports pretty stable threads, but there are still some major issues with them, for example creating a thread under iThreads is several orders of magnitude slower than forking a separate process. For other issues follow the perl5-porters mailing list, or grep the archives for Elizabeth Mattijsen's posts.

      POE however is here, it works, and it does what its supposed to do really really well.

Re: POE::Component::Server::HTTP: The _signal event is deprecated
by ls (Scribe) on Dec 15, 2002 at 13:42 UTC
    Oops, I forgot to post some data that may be important

    OS: Win2k Professional
    Perl: 5.6.1 (Activestate 633)
    POE: 0.24
    POE::Component::Server::HTTP: 0.03

Re: POE::Component::Server::HTTP: The _signal event is deprecated
by rcaputo (Chaplain) on Dec 18, 2002 at 02:50 UTC

    This is a warning generated by POE::Component::Server::HTTP itself. Unfortunately, it's misattributed to your code.

    Visit line 68 in PoCo::Server::HTTP, and comment out the line that reads:

      _signal => sub {},

    I've already submitted a bug report to the component's author.

    -- Rocco Caputo - troc@pobox.com - poe.perl.org

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://219990]
Approved by BrowserUk
Front-paged by wil
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2025-06-17 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.