On Feb 21, 2007, at 15:05, Kevin Scaldeferri wrote:
I'm trying to figure out how to schedule an action to happen after
my PoCo::Server::TCP shuts down. I.e., after all the pending
requests have finished processing. I tried doing it through _stop
like this, but it didn't work:
POE::Component::Server::TCP->new
( Alias => 'server',
Port => $port,
ClientFilter => 'POE::Filter::HTTPD',
ClientInput => \&dispatch,
PackageStates => [ main => [ ...
"_stop"
],
],
);
...
In fact, _stop() was never called.
PackageStates are for the client sessions, not the server itself.
The component starts a single session to listen for connections, and
one session per connection. The various /.*States/ parameters are to
add new event handlers to the connections' sessions, not the server's.
The server itself won't _stop until it's shut down. $kernel->post
( server => "shutdown" ). It will keep listening for connections
until that happens.
I see that PoCo::Server::TCP can take a Started callback, but no
Stopped/Shutdown callback.
Patches are welcome. This should be really easy.
Is there some other way I should be approaching this?
You'll want to use call() rather than post(), for reasons already
explained.
I think I mentioned this in IRC. You can do this from
ClientDisconnected callbacks if you maintain a semaphore and a
shutdown flag. Catching a callback from the server's _stop is
probably a lot easier, though.
--
Rocco Caputo - [EMAIL PROTECTED]