We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 495682a commit 5a7e309Copy full SHA for 5a7e309
1 file changed
t/lib/Mojo/IOLoop/ReadWriteProcess/Test/Utils.pm
@@ -1,18 +1,19 @@
1
package Mojo::IOLoop::ReadWriteProcess::Test::Utils;
2
3
our @EXPORT_OK = qw(attempt);
4
-
+use Time::HiRes qw(sleep);
5
use Exporter 'import';
6
use constant DEBUG => $ENV{MOJO_PROCESS_DEBUG};
7
8
sub attempt {
9
my $attempts = 0;
10
my ($total_attempts, $condition, $cb, $or)
11
= ref $_[0] eq 'HASH' ? (@{$_[0]}{qw(attempts condition cb or)}) : @_;
12
+ $cb //= sub {1};
13
until ($condition->() || $attempts >= $total_attempts) {
14
warn "Attempt $attempts" if DEBUG;
15
$cb->();
- sleep 1;
16
+ sleep .1;
17
$attempts++;
18
}
19
$or->() if $or && !$condition->();
0 commit comments