Re: Initialization of object once per thread
Darren Ball <[email protected]> Wed, 15 Apr 2015 11:28:09 -0400
| Newsgroups | gmane.comp.java.grinder.devel |
|---|---|
| Message-ID | <CA+YPNhdCkNg6yROFJBE57h1H7gYud331uvRmdMmb3enq+170pw@mail.gmail.com> |
--===============1368241796850560180==
Content-Type: multipart/alternative; boundary=001a1141b44ad799760513c4ff37
--001a1141b44ad799760513c4ff37
Content-Type: text/plain; charset=UTF-8
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 <[email protected]> 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
>
--001a1141b44ad799760513c4ff37
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">This is exactly what I am getting along with the script, a=
ny insight as to why the object is not available inside of the __call__ met=
hod would be great.<div><br><div><br></div><div><div>2015-04-15 15:25:14,76=
8 INFO =C2=A0i-ccfd793a-1 thread-0: starting, will do 1 run</div><div>2015-=
04-15 15:25:14,768 INFO =C2=A0i-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.gr=
inder.scriptengine.jython.JythonScriptExecutionException: Java exception ca=
lling TestRunner</div><div><span class=3D"" style=3D"white-space:pre"> </sp=
an>createAppPerf.createApp(1,100)</div><div><span class=3D"" style=3D"white=
-space:pre"> </span>File "/home/grinder/./i-ccfd793a-file-store/curren=
t/createapp.py", line 13, in __call__</div><div>java.lang.NullPointerE=
xception: null</div></div><div><br></div><div>The script:</div><div><br></d=
iv><div><div>from net.grinder.script import Test</div><div>from net.grinder=
.script.Grinder import grinder</div><div>from com.myapp.api.controllers.per=
f.app import CreateAppPerf</div><div><br></div><div>createAppTest =3D Test(=
1, "Create APP 1 Table 100 Fields")</div><div>createAppPerf =3D C=
reateAppPerf()</div><div>createAppPerf.initialize()</div><div>createAppTest=
.record(createAppPerf.createApp)</div><div><br></div><div><br></div><div>cl=
ass TestRunner:</div><div>=C2=A0 =C2=A0 def __call__(self):</div><div>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 createAppPerf.createApp(1,100)</div></div><div><br=
></div></div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote=
">On Wed, Apr 15, 2015 at 11:05 AM, Darren Ball <span dir=3D"ltr"><<a hr=
ef=3D"mailto:[email protected]" target=3D"_blank">[email protected]=
</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin=
:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">H=
i All,<br><br>I recently found the following example online:<br><br><blockq=
uote style=3D"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 l=
evel of your script.</blockquote><br><blockquote style=3D"margin:0px 0px 0p=
x 40px;border:none;padding:0px">from mypackage import MyTest<br><br>myTest =
=3D 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 point=
er 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 =3D CreateAppPerf()</div><div>createAppPerf.i=
nitialize()</div><div><br></div><div>createAppTest =3D Test(1, "Create=
APP 1 Table 100 Fields")</div><div>createAppTest.record(createAppPerf=
.createApp)</div><div><br></div><div>class TestRunner:</div><div>=C2=A0 =C2=
=A0 def __call__(self):</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 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__ metho=
d works, but this is not what I would like.=C2=A0 I would to initialize onl=
y 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</div></div>
</blockquote></div><br></div>
--001a1141b44ad799760513c4ff37--
--===============1368241796850560180==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
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
--===============1368241796850560180==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Grinder-development mailing list
Grinder-development-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/grinder-development
--===============1368241796850560180==--