view release on metacpan or search on metacpan
t/20-timeout.t view on Meta::CPAN
on_recv => $cb,
timeout => 3, on_timeout => sub { $cb->croak("Timeout") },
rtimeout => 4.5, on_rtimeout => sub { $cb2->croak("Read Timeout") }
);
my $start_time = AE::now;
like(exception { $cb->recv }, qr/Timeout/, 'Receive throws a timeout');
cmp_ok AE::now, '>=', $start_time + 3, 'Three seconds have passed';
like(exception { $cb2->recv }, qr/Read Timeout/, 'Receive throws a timeout again');
cmp_ok AE::now, '>=', $start_time + 4.5, '1.5 more seconds have passed';
$server->timeout_reset;
my $cb3 = AE::cv;
$server->on_timeout(sub { $cb3->croak('Reset') });
like(exception { $cb3->recv }, qr/Reset/, 'Receive throws a timeout again');
cmp_ok AE::now, '>=', $start_time + 7.5, '3 more seconds have passed';
}
done_testing;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
these.
=item $local_port = port
Create a new local port object and returns its port ID. Initially it has
no callbacks set and will throw an error when it receives messages.
=item $local_port = port { my @msg = @_ }
Creates a new local port, and returns its ID. Semantically the same as
creating a port and calling C<rcv $port, $callback> on it.
}
=item peval $port, $coderef[, @args]
Evaluates the given C<$codref> within the context of C<$port>, that is,
when the code throws an exception the C<$port> will be killed.
Any remaining args will be passed to the callback. Any return values will
be returned to the caller.
This is useful when you temporarily want to execute code in the context of
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
If you don't want to go to the effort of subclassing this module, you can
also specify all event handlers as constructor keys.
=head1 EXAMPLES
Here are some real-world code snippets, thrown in here mainly to give you
some example code to copy.
=head2 doomfrontend
At one point I replaced mythtv-frontend by my own terminal-based video
view all matches for this distribution
view release on metacpan or search on metacpan
t/01_construct.t view on Meta::CPAN
my $content = shift;
#say "on_unchange execute";
#say qq(content is "$content");
},
on_error => sub {
#say "on_error execute. throw process.";
$cv->send;
},
], "interval simple digit version");
my $paste_tick2 = new_ok( 'AnyEvent::Mac::Pasteboard', [
t/01_construct.t view on Meta::CPAN
my $content = shift;
#say "on_unchange execute";
#say qq(content is "$content");
},
on_error => sub {
#say "on_error execute. throw process.";
$cv->send;
},
], "interval arrayref that contains some digits version");
my $timeout = AE::timer $TIMEOUT_SEC, 0, sub { $cv->send(); };
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
t/00-load.t view on Meta::CPAN
use Test::More;
use Test::Exception;
use_ok('AnyEvent::Monitor::CPU');
throws_ok sub { AnyEvent::Monitor::CPU->new },
qr/Required parameter 'cb' not found, /;
throws_ok sub { AnyEvent::Monitor::CPU->new(cb => 1) },
qr/Parameter 'cb' must be a coderef, /;
done_testing();
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
t/02client.t view on Meta::CPAN
$object->delete;
# delete a non-existant object
$object = $bucket->object( key => 'not here' );
throws_ok { $object->get } qr/NoSuchKey/,
'getting non-existant object throws exception';
# upload a file with put_filename
$object = $bucket->object( key => 'the readme' );
$object->put_filename('README');
t/02client.t view on Meta::CPAN
read($tmp_fh, $test_bytes, 2);
is($test_bytes, "xz", "The second chunk of the file begins in the correct place");
#test listing a multipart object
$stream = $bucket->list({prefix => 'new multipart file'});
lives_ok {my @items = $stream->items} 'Listing a multipart file does not throw an exeption';
$object->delete;
#test multi-object delete
#make 3 identical objects
view all matches for this distribution
view release on metacpan or search on metacpan
t/74-exception.t view on Meta::CPAN
use AnyEvent::Net::Curl::Queued;
use AnyEvent::Net::Curl::Queued::Easy;
## no critic (ProhibitComplexRegexes)
throws_ok
{ AnyEvent::Net::Curl::Queued->new(1 .. 3) }
qr(^Should\s+be\s+initialized\s+as\s+AnyEvent::Net::Curl::Queued->new\b)sx,
q(non-hash used to initialize AnyEvent::Net::Curl::Queued);
throws_ok
{ AnyEvent::Net::Curl::Queued::Easy->new(1 .. 3) }
qr(^Should\s+be\s+initialized\s+as\s+AnyEvent::Net::Curl::Queued::Easy->new\b)sx,
q(non-hash used to initialize AnyEvent::Net::Curl::Queued::Easy);
done_testing(2);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Open3/Simple.pm view on Meta::CPAN
say 'exit value: ', $exit_value;
say 'signal: ', $signal;
$done->send;
},
on_error => sub {
my $error = shift; # the exception thrown by IPC::Open3::open3
my $program = shift; # string
my @args = @_; # list of arguments
warn "error: $error";
$done->send;
},
lib/AnyEvent/Open3/Simple.pm view on Meta::CPAN
=item * C<on_error> ($error, $program, @arguments)
Called when there is an execution error, for example, if you ask
to run a program that does not exist. No process is passed in
because the process failed to create. The error passed in is
the error thrown by L<IPC::Open3> (typically a string which begins
with "open3: ...").
In some environments open3 is unable to detect exec errors in the
child, so you may not be able to rely on this event. It does
seem to work consistently on Perl 5.14 or better though.
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/PgRecvlogical.pm view on Meta::CPAN
=item L<Int|Types::Standard/Int>, Default: C<1>
=back
Number of times to attempt reconnecting. If this limit is exceded, an exception will be thrown.
=item C<heartbeat>
=over
lib/AnyEvent/PgRecvlogical.pm view on Meta::CPAN
# uncoverable statement count:2
AE::postpone { $self->_handle_disconnect };
0;
};
# exception thrown, going to reconnect
return unless $ok; # uncoverable branch true
# nothing waiting
# watcher will re-enter until $n == 0
return if $n == 0;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/ProcessPool.pm view on Meta::CPAN
=head1 DIAGNOSTICS
=head2 Task errors
Error messages resulting from a C<die> or C<croak> in task code executed in a
worker process are rethrown in the parent process when the condition variable's
C<recv> method is called.
=head2 "AnyEvent::ProcessPool::Worker: ..." (warning)
When a worker sub-process emits output to C<STDERR>, the process pool warns
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Promise.pm view on Meta::CPAN
will block until the guarding condvar is fulfilled.
Errors in the callbacks can be caught by setting an exception handler via the
L</catch> method on the promise instance. This method will catch exceptions
raised from L<AnyEvent> objects and exceptions raised in blocks provided to
L</then>. If an error is encountered in the chain, an exception will be thrown
and the rest of the chain will be skipped, jumping straight to the catch
callback.
=head1 EXPORT
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Promises.pm view on Meta::CPAN
The handler (either C<$on_fulfilled> or C<$on_rejected>) is called in
a list context so it can return multiple values (here it differs from JavaScript
implementation).
If the handler throws an exception, then C<$pp> is rejected with the
exception.
If the handler does not throw an exception and does not return a
promise, then C<$pp> is fulfilled with the values returned by the handler.
If the handler returns a promise, then C<$pp> is fulfilled/rejected
when the promise returned is fulfilled/rejected with the same values/reason.
lib/AnyEvent/Promises.pm view on Meta::CPAN
);
With C<Promises> the C<$p> promise is finally rejected with C<$reason>,
while with C<AnyEvent::Promises> the C<$promise> is finally fulfilled
with C<$reason>, because the exception was handled (the handler did not
throw an exception).
=item L<https://github.com/kriskowal/q/wiki/API-Reference>
Here I shamelessly copied the ideas from.
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/RabbitMQ/LocalQueue.pm view on Meta::CPAN
my ($self, $frame) = @_;
$self->_drain_queue;
while (my $cb = shift @{$self->{_drain_code_queue}}) {
local $@; # Flush frames immediately, throwing away errors for on-close
eval { $cb->($frame) };
}
}
1;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Retry/Coro.pm view on Meta::CPAN
});
};
sub DEMOLISH {
my $self = shift;
$self->running_coro->throw('DEMOLISH');
}
sub wait {
my ($status, @args) = Coro::rouse_wait();
return $args[0] if $status eq 'success';
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution