Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problems when using with TIme::Out #2

Open
michael-stevens opened this issue Jul 14, 2023 · 0 comments
Open

problems when using with TIme::Out #2

michael-stevens opened this issue Jul 14, 2023 · 0 comments

Comments

@michael-stevens
Copy link

I get a broken looking internal exception when using with Time::Out:

#!/usr/bin/perl -w

use strict;
use warnings;
use HTTP::Tiny;
use Time::HiRes qw(gettimeofday tv_interval);
use Time::Out qw(timeout);
use Data::Dumper;

my $url = "https://www.etla.org/";
my $res;
my $tiny = new HTTP::Tiny;

my      $t0 = [gettimeofday];

$res = $tiny->post($url);
my       $elapsed = tv_interval ( $t0 );

print "Elapsed: $elapsed\n";

timeout 0.01 => sub {
        $res = $tiny->post($url);
};

if ($@) {
        print STDERR "Error: $@\n";
}


print "Status: $res->{status}\n";
print Dumper($res);

Output:

Elapsed: 0.373522
Status: 599
$VAR1 = {
          'success' => '',
          'headers' => {
                         'content-type' => 'text/plain',
                         'content-length' => 14
                       },
          'status' => 599,
          'content' => 'CODE(0xed00e0)',
          'reason' => 'Internal Exception',
          'url' => 'https://www.etla.org/'
        };

You kind of want to say “it’s timeing out, of course it fails”, but:

a) content in this scenario is documented to be a meaningful message, not CODE(0x20170e0) so it’s behaving contrary to documentation

b) if you debug a bit and find out what that coderef returns, it’s actually a full, valid looking, response object, suggesting that the response was complete and successful, not a timeout.

Perl is a little old:

This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
(with 44 registered patches, see perl -V for more detail)

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the

On CentOS 7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant