[Dev] Test script with concurrent threads
Frank Cohen
fcohen at pushtotest.com
Thu May 24 22:25:15 PDT 2007
Here's the URL to an article on writing Jython scripts using Threads:
http://www.pushtotest.com/Docs/howto/jythonthreads.html
-Frank
On May 24, 2007, at 11:22 AM, Filipa Martins Soares Abrantes wrote:
> Thank you William for your response.
>
> I've executed without the parenthesis, like thread.start_new_thread
> ( test.runTest, (i,)), but now I'm getting the following error:
>
> Traceback (innermost last):
>
> (no code object) at line 0
>
> TypeError: runTest() too many arguments; expected 1 got 2
>
>
>
> Any idea?
>
> Thanks,
>
> Filipa
>
> On 5/24/07, William Martínez Pomares <wmartinez at avanticatec.net>
> wrote:
> Hi Filipa.
>
> Sorry for the late response. Since this is the third post without
> answer, I thought I take a look althought I'm not a Python expert.
>
> I found something in the line "thread.start_new_thread( test.runTest
> (), (i,))" but I'm not sure.
> As I understand from what I just read in internet, the
> start_new_thread() method receives two parameters: a method and a
> tuple with arguments to pass to the method.
>
> That means, the first parameter is the method you want to call.
> But, you don't need to call it, you just need to pass the method.
> In the line above, you are actually executing test.runTest() due to
> the parenthesis!
> I think the line should be: "thread.start_new_thread( test.runTest,
> (i,))", note there are no parenthesis in runTest.
> With your line, you are first executing runTest(), and the result
> is passed to start_new_thread(). If runTest() returns a method,
> then the call is correct, but I think that is not your case.
>
> Please remove the parenthesis from runTest and try it, then let me
> know if it works. Again, I'm not an expert, so good luck.
>
> William Martínez Pomares
> R&D Manager and Architect
> Avantica Technologies
> Phone(US) :+1 (650) 353-4522 Ext 131
> Fax(US) :+1 (877) 372-1955
> Phone(CR) :+506 283-9100 Ext 131
> Fax(CR) :+506 253-7451
> http://www.avantica.net
>
> -----Original Message-----
> From: dev-bounces at lists.pushtotest.com [mailto:dev-
> bounces at lists.pushtotest.com]On Behalf Of Filipa Martins Soares
> Abrantes
> Sent: Thursday, May 24, 2007 2:23 AM
> To: fcohen at pushtotest.com ; PushToTest TestMaker Developers List
> Subject: [Dev] Test script with concurrent threads
>
>
> Hi!
>
> I'm still trying to execute a test script with concurrent threads,
> but the threads are being executed in a sequential order instead.
> Can anyone tell me how can put the threads executing concurrently?
>
> I really need some help!
>
> This is the code I'm executing:
>
>
> numThread = 3
> numThreadPerBlocks = 5
> fimThread = 0
> tinicio = Date().time
>
> while (i < numThread):
> x = 0
> if (numThread - i < numThreadPerBlocks):
> numThreadPerBlocks = numThread - i
>
> while (x < numThreadPerBlocks):
> print "Start thread ", i
> test = Portal5( 1, 'console file ', 0, '20.|300|301|
> 302|303|304|307|401|403|408|41.', ' log.xml', 5, 5, 5, 1, 1,
> 'Portal5', 1 )
> test.setUp()
> thread.start_new_thread( test.runTest(), (i,))
> x += 1
> i += 1
> time.sleep(10)
>
> time.sleep (40)
> print "Stop between blocks"
>
> while (fimThread < i):
> time.sleep(1)
>
> This is my text output:
>
> Start thread 0
> Portal5: Initialize
> test: setUp
> test: runTest
> Request step: 1, http://www1.asd.pt/PortalWeb/content/
> Request step: 2, http://www1.asd.pt/PortalWeb/content/
> ..
> Start thread 1
> Portal5: Initialize
> test: setUp
> test: runTest
> Request step: 1, http://www1.asd.pt/PortalWeb/content/
> Request step: 2, http://www1.asd.pt/PortalWeb/content/
>
>
>
> Thanks in advance,
> Filipa
>
> _______________________________________________
> Dev mailing list
> Dev at lists.pushtotest.com
> http://lists.pushtotest.com/mailman/listinfo/dev
>
>
>
>
> --
> Filipa M. Soares Abrantes
> _______________________________________________
> Dev mailing list
> Dev at lists.pushtotest.com
> http://lists.pushtotest.com/mailman/listinfo/dev
--
Frank Cohen, PushToTest, http://www.PushToTest.com, phone 408 374 7426
TestMaker: The open-source SOA test automation tool
More information about the Dev
mailing list