[prev in list] [next in list] [prev in thread] [next in thread]
List: grinder-development
Subject: Re: [Grinder-development] Initialization of object once per thread
From: Philip Aston <philipa () mail ! com>
Date: 2015-04-15 18:24:01
Message-ID: 552EACC1.3020303 () mail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi Darren,
This really belongs on grinder-use - grinder-development is for the
development of the grinder and has fewer subscribers.
Anyway, its hard to say exactly because I don't know what CreateAppPerf
does. The full stack trace from the output log would help.
The difference between code executed at the top level and that executed
from TestRunner.__init__() or __call__() is that the former is not
executed in a worker thread, so can't itself call instrumented code. I
suspect that's the problem. You could try moving the
"createAppTest.record(createAppPerf.createApp)" line to
TestRunner.__init__(). Calling record multiple times for the same Test
and target is essentially a no-op.
- Phil
On 15/04/15 16:28, Darren Ball wrote:
> This is exactly what I am getting along with the script, any insight
> as to why the object is not available inside of the __call__ method
> would be great.
>
>
> 2015-04-15 15:25:14,768 INFO i-ccfd793a-1 thread-0: starting, will do
> 1 run
> 2015-04-15 15:25:14,768 INFO i-ccfd793a-1 : start time is
> 1429111514767 ms since Epoch
> 2015-04-15 15:25:14,851 ERROR i-ccfd793a-1 thread-0 [ run-0 ]: aborted
> run - Java exception calling TestRunner
> net.grinder.scriptengine.jython.JythonScriptExecutionException: Java
> exception calling TestRunner
> createAppPerf.createApp(1,100)
> File "/home/grinder/./i-ccfd793a-file-store/current/createapp.py",
> line 13, in __call__
> java.lang.NullPointerException: null
>
> The script:
>
> from net.grinder.script import Test
> from net.grinder.script.Grinder import grinder
> from com.myapp.api.controllers.perf.app import CreateAppPerf
>
> createAppTest = Test(1, "Create APP 1 Table 100 Fields")
> createAppPerf = CreateAppPerf()
> createAppPerf.initialize()
> createAppTest.record(createAppPerf.createApp)
>
>
> class TestRunner:
> def __call__(self):
> createAppPerf.createApp(1,100)
>
>
> On Wed, Apr 15, 2015 at 11:05 AM, Darren Ball <balldarrens@gmail.com
> <mailto:balldarrens@gmail.com>> wrote:
>
> Hi All,
>
> I recently found the following example online:
>
> If you want one instance for all worker threads in a process,
> call it
> from the top level of your script.
>
>
> from mypackage import MyTest
>
> myTest = MyTest()
> myTest.init()
>
> class TestRunner:
> def __call__(self):
> # use myTest
>
> I have this exact code with onle the MyTest object being the
> differentiator, and in the call I get a null pointer exception.
>
>
> from net.grinder.script import Test
> from net.grinder.script.Grinder import grinder
> from com.myapp.api.controllers.perf.app import CreateAppPerf
>
> createAppPerf = CreateAppPerf()
> createAppPerf.initialize()
>
> createAppTest = Test(1, "Create APP 1 Table 100 Fields")
> createAppTest.record(createAppPerf.createApp)
>
> class TestRunner:
> def __call__(self):
> createAppPerf.createApp(1,100)
>
>
>
> Moving the createAppPerf.initialize() to the __init__ method
> works, but this is not what I would like. I would to initialize
> only once.
>
> Any suggestions as how to do this so that createAppPerf is not
> null in __call__?
>
>
> Thanks,
> Darren
>
[Attachment #5 (text/html)]
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi Darren,<br>
<br>
This really belongs on grinder-use - grinder-development is for
the development of the grinder and has fewer subscribers.<br>
<br>
Anyway, its hard to say exactly because I don't know what
CreateAppPerf does. The full stack trace from the output log would
help.<br>
<br>
The difference between code executed at the top level and that
executed from TestRunner.__init__() or __call__() is that the
former is not executed in a worker thread, so can't itself call
instrumented code. I suspect that's the problem. You could try
moving the "createAppTest.record(createAppPerf.createApp)" line to
TestRunner.__init__(). Calling record multiple times for the same
Test and target is essentially a no-op.<br>
<br>
- Phil<br>
<br>
<br>
<br>
On 15/04/15 16:28, Darren Ball wrote:<br>
</div>
<blockquote
cite="mid:CA+YPNhdCkNg6yROFJBE57h1H7gYud331uvRmdMmb3enq+170pw@mail.gmail.com"
type="cite">
<div dir="ltr">This is exactly what I am getting along with the
script, any insight as to why the object is not available inside
of the __call__ method would be great.
<div><br>
<div><br>
</div>
<div>
<div>2015-04-15 15:25:14,768 INFO i-ccfd793a-1 thread-0:
starting, will do 1 run</div>
<div>2015-04-15 15:25:14,768 INFO i-ccfd793a-1 : start time
is 1429111514767 ms since Epoch</div>
<div>2015-04-15 15:25:14,851 ERROR i-ccfd793a-1 thread-0 [
run-0 ]: aborted run - Java exception calling TestRunner</div>
<div>net.grinder.scriptengine.jython.JythonScriptExecutionException:
Java exception calling TestRunner</div>
<div><span class="" style="white-space:pre"> </span>createAppPerf.createApp(1,100)</div>
<div><span class="" style="white-space:pre"> </span>File
"/home/grinder/./i-ccfd793a-file-store/current/createapp.py",
line 13, in __call__</div>
<div>java.lang.NullPointerException: null</div>
</div>
<div><br>
</div>
<div>The script:</div>
<div><br>
</div>
<div>
<div>from net.grinder.script import Test</div>
<div>from net.grinder.script.Grinder import grinder</div>
<div>from com.myapp.api.controllers.perf.app import
CreateAppPerf</div>
<div><br>
</div>
<div>createAppTest = Test(1, "Create APP 1 Table 100
Fields")</div>
<div>createAppPerf = CreateAppPerf()</div>
<div>createAppPerf.initialize()</div>
<div>createAppTest.record(createAppPerf.createApp)</div>
<div><br>
</div>
<div><br>
</div>
<div>class TestRunner:</div>
<div> def __call__(self):</div>
<div> createAppPerf.createApp(1,100)</div>
</div>
<div><br>
</div>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Apr 15, 2015 at 11:05 AM,
Darren Ball <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:balldarrens@gmail.com" target="_blank">balldarrens@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi All,<br>
<br>
I recently found the following example online:<br>
<br>
<blockquote style="margin:0px 0px 0px
40px;border:none;padding:0px">If you want one instance
for all worker threads in a process, call it<br>
from the top level of your script.</blockquote>
<br>
<blockquote style="margin:0px 0px 0px
40px;border:none;padding:0px">from mypackage import
MyTest<br>
<br>
myTest = MyTest()<br>
myTest.init()<br>
<br>
class TestRunner:<br>
def __call__(self):<br>
# use myTest<br>
<br>
</blockquote>
I have this exact code with onle the MyTest object being
the differentiator, and in the call I get a null pointer
exception.
<div><br>
</div>
<div><br>
<div>
<div>
<div>from net.grinder.script import Test</div>
<div>from net.grinder.script.Grinder import grinder</div>
<div>from com.myapp.api.controllers.perf.app import
CreateAppPerf</div>
<div><br>
</div>
<div>createAppPerf = CreateAppPerf()</div>
<div>createAppPerf.initialize()</div>
<div><br>
</div>
<div>createAppTest = Test(1, "Create APP 1 Table 100
Fields")</div>
<div>createAppTest.record(createAppPerf.createApp)</div>
<div><br>
</div>
<div>class TestRunner:</div>
<div> def __call__(self):</div>
<div> createAppPerf.createApp(1,100)</div>
</div>
</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>Moving the createAppPerf.initialize() to the __init__
method works, but this is not what I would like. I
would to initialize only once.</div>
<div><br>
</div>
<div>Any suggestions as how to do this so that
createAppPerf is not null in __call__?</div>
<div><br>
</div>
<div><br>
</div>
<div>Thanks,<br>
Darren<br>
</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
<br>
</body>
</html>
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Grinder-development mailing list
Grinder-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/grinder-development
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic