The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

#!/usr/bin/perl
use strict;
use Coro;
use Data::Dump 'pp';
my $couch = couch();
my $bad = couch('http://bad/');
my $done = AnyEvent->condvar;
sub p(&) {
$done->begin;
my $code = shift;
my $data;
eval { $data = $code->(); };
if ($@) {
print $@, "\n";
} else {
print pp($data), "\n";
}
$done->end;
}
async { print "hello, world\n" };
for (1 .. 4) {
async { p { ($couch->info->recv) } };
async { p { ($couch->all_dbs->recv) } };
async { p { ($bad->info->recv) } };
async { p { ($bad->all_dbs->recv) } };
}
async { print "hello, again, world\n" };
async { print "*** please be patient, and let the bad requests timeout. ***\n" };
async {
$done->recv;
print "----\n";
print "Did you see how the bad requests didn't stop the good requests?\n";
exit;
};
schedule;