Re: [Grinder-use] Grinder Connection Timeouts
Distributed load testing framework - Java, Jython, or Clojure scripts.
Brought to you by:
philipa
|
From: Philip A. <ph...@ma...> - 2013-10-10 10:04:12
|
Hmmm.
Your example looks good.
No, HTTPRequest does not create a different thread.
However, it looks to me like there are several places where the
HTTPClient library catches and swallows an InterruptedException. It
really shouldn't do this. Can you compile The Grinder from source? If
so, it would be worth trying a quick change to line 215 of
HTTPClient.HttpOutputStream. Instead of:
while (resp == null)
try { wait(); } catch (InterruptedException ie) { }
say
while (resp == null)
try { wait(); } catch (InterruptedException ie) {
throw new RuntimeException("Interrupted!);
}
I'm pretty sure that's the culprit.
- Phil
On 08/10/13 09:48, Benedict Dodd wrote:
> Thanks Phil,
>
> Sorry, I added that raise as part of an attempt to get it to work.
>
> I have created a basic example:
> https://gist.github.com/bendodd/85968850b4629a52bb1b
>
> The code example you gave works if you just use grinder.sleep() to
> create the delay in execution, but if you do a http request, I assume,
> it creates another thread?
>
> For my example, the timer triggers but does not interrupt the request
> (the application used just takes the request and sleeps for the
> specified time).
>
> Thanks for your help, I appreciate this is now well above and beyond…
>
> Thanks, Ben
>
> On Tuesday, 8 October 2013 at 08:03, Philip Aston wrote:
>
>> That's because you've added a "raise RuntimeError" line. Remove it
>> from Interrupter.
>>
>> - Phil
>>
>> On 07/10/13 12:36, Benedict Dodd wrote:
>>> Hi Phil,
>>>
>>> Thank you for both your clarification and the coding example.
>>>
>>> I am, however, unable to get the example working. It seems that the
>>> example below, or at least how I've implemented it, only interrupts
>>> the timer thread and not the thread making the request, no?
>>>
>>> Using this:
>>>
>>> class Interrupter(TimerTask):
>>> def __init__(self):
>>> self.t = Thread.currentThread()
>>>
>>> def run(self):
>>> self.t.interrupt()
>>> raise RuntimeError('Timed Out!')
>>>
>>> And this
>>>
>>> def timeout_fail(self):
>>> t = Timer()
>>> t.schedule(Interrupter(), 4000)
>>> request101 = HTTPRequest(url=URL_MOCK, headers=headers0)
>>> result = request101.GET('/sleep/10000')
>>> t.cancel()
>>>
>>> I get this:
>>>
>>> Exception in thread "Timer-2" Traceback (most recent call last):
>>> File "lib/common.py", line 100, in run
>>> raise RuntimeError('Timed Out!')
>>> RuntimeError: Timed Out!
>>>
>>> Thanks, as ever, for your help, Ben
>>>
>>> On Sunday, 6 October 2013 at 17:28, Philip Aston wrote:
>>>
>>>> 1. Yes.
>>>>
>>>> 2. Code a timeout yourself. Here's a hint
>>>>
>>>> from java.util import Timer, TimerTask
>>>> from java.lang import Thread, InterruptedException
>>>>
>>>> t = Timer(True)
>>>>
>>>> class Interrupter(TimerTask):
>>>> def __init__(self):
>>>> self.t =Thread.currentThread()
>>>>
>>>> def run(self):
>>>> self.t.interrupt()
>>>>
>>>> t.schedule(Interrupter(), 1000)
>>>>
>>>> try:
>>>> Thread.sleep(2000)
>>>> print "Slept through the night"
>>>> except InterruptedException:
>>>> print "Rudely interrupted"
>>>>
>>>> 3. See #2.
>>>>
>>>>
>>>> HTH,
>>>>
>>>> - Phil
>>>>
>>>>
>>>> On 01/10/13 19:20, Benedict Dodd wrote:
>>>>> Hello Grind-a-trons
>>>>>
>>>>> I'd been under the impression that setting a connection timeout would curtain all connections at the set limit. However, if I'm reading this correctly, it will continue past the set value as long as the remote server is trickling data back:
>>>>> http://grinder.sourceforge.net/g3/script-javadoc/net/grinder/plugin/http/HTTPPluginConnection.html#setTimeout(int) <http://grinder.sourceforge.net/g3/script-javadoc/net/grinder/plugin/http/HTTPPluginConnection.html#setTimeout%28int%29>
>>>>>
>>>>> 1. Is that correct?
>>>>> 2. Is there a good way to put a hard limit on a request time?
>>>>> 3. Is there a good way to catch timeout exceptions?
>>>>>
>>>>> Thanks, Ben
>>>>>
>>>>>
|