Re: [Grinder-use] Grinder Connection Timeouts
Distributed load testing framework - Java, Jython, or Clojure scripts.
Brought to you by:
philipa
|
From: Benedict D. <ben...@gm...> - 2013-10-08 08:48:28
|
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 > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk > > _______________________________________________ > grinder-use mailing list > gri...@li... (mailto:gri...@li...) > https://lists.sourceforge.net/lists/listinfo/grinder-use > > |