Skip Menu |

This queue is for tickets about the Lingua-AtD CPAN distribution.

Report information
The Basics
Id: 77309
Status: resolved
Worked: 2.2 hours (130 min)
Priority: 0/
Queue: Lingua-AtD

People
Owner: DDAY [...] cpan.org
Requestors: BBYRD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.113000
Fixed in: (no value)



Subject: SYNOPSIS example silently fails on second test
use Lingua::AtD; my $atd = Lingua::AtD->new( { host => 'service.afterthedeadline.com', port => 80 }); print "Checking document..."; my $atd_response = $atd->check_document('Text to check.'); print "done!\n"; print "Checking grammar..."; my $atd_response = $atd->check_grammar('Text to check.'); die "THIS NEVER EXECUTES!"; WTF?!? So, no repeat tests? Even then, why the silent failure?
Bug verified. Shouldn't fail silently and should permit repeat tests. Working on it now. On Sun May 20 14:02:56 2012, BBYRD wrote: Show quoted text
> use Lingua::AtD; > > my $atd = Lingua::AtD->new( { > host => 'service.afterthedeadline.com', > port => 80 > }); > > print "Checking document..."; > my $atd_response = $atd->check_document('Text to check.'); > print "done!\n"; > > print "Checking grammar..."; > my $atd_response = $atd->check_grammar('Text to check.'); > die "THIS NEVER EXECUTES!"; > > WTF?!? So, no repeat tests? Even then, why the silent failure?
Okay - I think I've figured it out. First, yes the code is broken. It's supposed to throw an HTTPException when LWP::UserAgent receives an error (i.e. 404, 503, etc). It's not, and I'll have to figure that out. Maybe it's best just to die at that point rather than throw an exception. Let me know what you think. Second, apparently there's a throttle on the service. I've found that if I sleep for one second between calls, everything's fine. But without it, I get a 503 on the second call. So I'll also add in a default throttle property that can be overridden. I'll experiment to find what seems to be reasonable and also ask on the AtD message boards about throttling. The API document says nothing. Finally, my examples need cleaned up, so I'll try to cover that as well. If I'm throwing exceptions and expect them to be caught, I need to demonstrate how that works. This may take me a week or so to straighten out, but if you sleep for one second between calls for now, that'll keep you moving forward.
Subject: Re: [rt.cpan.org #77309] SYNOPSIS example silently fails on second test
Date: Wed, 30 May 2012 11:43:46 -0400
To: bug-Lingua-AtD [...] rt.cpan.org
From: Brendan Byrd <Perl [...] ResonatorSoft.org>
On Tue, May 22, 2012 at 9:20 PM, David L. Day via RT <bug-Lingua-AtD@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=77309 > > > Okay - I think I've figured it out. > > First, yes the code is broken. It's supposed to throw an HTTPException > when LWP::UserAgent receives an error (i.e. 404, 503, etc). It's not, > and I'll have to figure that out. Maybe it's best just to die at that > point rather than throw an exception. Let me know what you think.
Well, the exception is probably the better way to go, but silent deaths are the worst possible scenario. Might want to just die as first until you can figure out how to get the exception to work, or have some sort of failsafe that will die if the exception doesn't come out. At least you now have a testable failure (double result to get a 503), which might be worth throwing in as a *.t test. (Test::Exception works wonders here.) Show quoted text
> Second, apparently there's a throttle on the service. I've found that if > I sleep for one second between calls, everything's fine. But without it, > I get a 503 on the second call. So I'll also add in a default throttle > property that can be overridden. I'll experiment to find what seems to > be reasonable and also ask on the AtD message boards about throttling. > The API document says nothing.
Yeah, just as long as it's based on some sort of internal timestamp, instead of an auto-sleep. For example, if the user does a AtD call, does two seconds worth of work, and then calls AtD again, L:AtD should make the API request right away, not sleep for an extra second. Show quoted text
> This may take me a week or so to straighten out, but if you sleep for > one second between calls for now, that'll keep you moving forward.
Thanks for the updates. Keep me posted. I'm looking at potentially creating a Test::Pod::Grammar module, using this module as its interface to AtD. -- Brendan Byrd <Perl@ResonatorSoft.org> Brendan Byrd <BBYRD@CPAN.org>
On Wed May 30 11:43:57 2012, Perl@ResonatorSoft.org wrote: Show quoted text
> On Tue, May 22, 2012 at 9:20 PM, David L. Day via RT > <bug-Lingua-AtD@rt.cpan.org> wrote:
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=77309 > > > > > Okay - I think I've figured it out. > > > > First, yes the code is broken. It's supposed to throw an HTTPException > > when LWP::UserAgent receives an error (i.e. 404, 503, etc). It's not, > > and I'll have to figure that out. Maybe it's best just to die at that > > point rather than throw an exception. Let me know what you think.
> > Well, the exception is probably the better way to go, but silent > deaths are the worst possible scenario. Might want to just die as > first until you can figure out how to get the exception to work, or > have some sort of failsafe that will die if the exception doesn't come > out. At least you now have a testable failure (double result to get a > 503), which might be worth throwing in as a *.t test. > (Test::Exception works wonders here.)
I replaced the exceptions with croak for now since it may take me awhile to sort out how best to use them in this case. Show quoted text
>
> > Second, apparently there's a throttle on the service. I've found that if > > I sleep for one second between calls, everything's fine. But without it, > > I get a 503 on the second call. So I'll also add in a default throttle > > property that can be overridden. I'll experiment to find what seems to > > be reasonable and also ask on the AtD message boards about throttling. > > The API document says nothing.
> > Yeah, just as long as it's based on some sort of internal timestamp, > instead of an auto-sleep. For example, if the user does a AtD call, > does two seconds worth of work, and then calls AtD again, L:AtD should > make the API request right away, not sleep for an extra second. >
I implemented a throttle, default of 1 second (seems to be enough) based on an internal timestamp as you suggested. Thank you! Show quoted text
> > This may take me a week or so to straighten out, but if you sleep for > > one second between calls for now, that'll keep you moving forward.
> > Thanks for the updates. Keep me posted. I'm looking at potentially > creating a Test::Pod::Grammar module, using this module as its > interface to AtD. >
I have a few housekeeping items before I release the fixes but I should have them wrapped up tomorrow evening at the latest.
I added new tests (about 20 of them) to verify the module works now. Closing out the ticket. New release made.