Permalink
Browse files

Work around session_pid_count() not working in 1.350 of POE

Reported as [rt.cpan.org #73393] by Gregor Herrmann of the Debian Perl Group
  • Loading branch information...
1 parent 7563890 commit a2d0a846b4d568b063c104e2a04b6a5f719fe983 @bingos committed Jan 11, 2012
Showing with 28 additions and 6 deletions.
  1. +1 −1 dist.ini
  2. +13 −1 lib/POE/API/Peek.pm
  3. +14 −4 t/08-pid.t
View
@@ -1,5 +1,5 @@
name = POE-API-Peek
-version = 2.19
+version = 2.20
author = sungo <sungo@sungo.us>
author = Yuval Kogman <nothingmuch@woobling.org>
author = Chris 'BinGOs' Williams <bingos@cpan.org>
View
@@ -1,6 +1,8 @@
package POE::API::Peek;
# ABSTRACT: Peek into the internals of a running POE environment
+=pod
+
=head1 DESCRIPTION
POE::API::Peek extends the POE::Kernel interface to provide clean access
@@ -842,13 +844,23 @@ Obtain a count of the process IDs being watched by a session. Takes one
optional parameter, a POE::Session object or ID. If this parameter is not
supplied, it will default to the currently active session.
+Since 1.350 of L<POE> it is no longer possible to query the number of
+processes a session is watching. This method is deprecated and will be
+removed in a future version.
+
=cut
sub session_pid_count {
my $self = shift;
my $session = shift || $self->current_session();
my $sid = ref $session ? $session->ID : $session;
- return $poe_kernel->_data_sig_pids_ses($sid);
+ my $ver = $POE::VERSION;
+ $ver =~ s/_.+$//;
+ if($ver < '1.350') {
+ return $poe_kernel->_data_sig_pids_ses($sid);
+ }
+ carp "session_pid_count() is not available for POE 1.350 and above\n";
+ return;
}
# }}}
View
@@ -9,19 +9,29 @@ use Test::More tests => 10;
use_ok('POE::API::Peek');
-my $api = POE::API::Peek->new();
-POE::Session->create(
+SKIP: {
+
+ my $ver = $POE::VERSION;
+ $ver =~ s/_.+$//;
+ skip "POE version less than 1.350 required for these tests", 9 unless $ver < '1.350';
+
+ my $api = POE::API::Peek->new();
+
+ POE::Session->create(
inline_states => {
_start => \&_start,
_stop => \&_stop,
dummy => sub {},
},
heap => { api => $api },
-);
+ );
+
+ POE::Kernel->run();
+}
-POE::Kernel->run();
+exit 0;
###############################################

0 comments on commit a2d0a84

Please sign in to comment.