Re: Thread terminating 10 seconds after entering __del__

Abdallah Khazaal <Abdallah.Khazaal-F0cRZVf0dWGrG/[email protected]>
Newsgroups gmane.comp.java.grinder.user
Message-ID <CF0DE3EF8EC31843A37D85A4E5B6057901BA04B5B72E@CPGEXMBCCR01.cpggpc.ad>
Thank you Phil! This solution worked for me.

It seems that  a related solution for this was suggested way back in 2005<http://grinder.996249.n3.nabble.com/Threadcontrol-about-the-Console-with-def-del-self-fails-td484.html> by Tobias Gindler.

I modified the source code (both the GrinderProcess.java and the AgentImplementation.java) in order to add a grinder.maximumShutdownTime property (as per suggestions above).
Rebuilt a custom version of the grinder-core-3.11.lib and was able to set this variable from the grinder.properties.

Regards,

Abdallah

From: Philip Aston [mailto:[email protected]]
Sent: Sunday, March 23, 2014 11:33 AM
To: grinder-use
Subject: Re: [Grinder-use] Thread terminating 10 seconds after entering __del__

Sorry, the 10 second grace period is not configurable. It applies to all "shutdown process", so it doesn't matter whether you use __del__, at_exit, or some other mechanism.

You could fork another process to do the copying, but that is probably best done from Java and may require work to ensure the child doesn't exit with the parent.

The simplest thing is probably to build a custom version of the grinder from source, and modify the timeout. (See GrinderProcess.java).

- Phil

On 19/03/14 15:10, Abdallah Khazaal wrote:
Hi All,

My script tries to execute “final code” in __del__ after all threads complete their work in __call__  (i.e. after the grinder.duration is reached).

    def __del__(self):
        # Wait for all other threads to complete before executing further
        self.finalCompleteBarrier.await()
        if grinder.getThreadNumber() == 0:
        # If this is Thread 0, retrieve files from remote server
        copyFiles()

This is working as expected except that the process is terminated before the copyFiles() procedure is completed.

My understanding is that the main thread doesn't terminate the worker threads and exists the process until 10 seconds pass after the worker threads signal that should exit.

In most cases, this should be enough time to finish executing the code in __del__ for each thread. However, in my case, if the copyFiles() procedure takes longer than 10 seconds (say because they are copied form remote server or the files are too big), then the process terminates before completing the job.

Is there a way to increase the 10 seconds waiting time to allow for more executing time in __del__?

If not, are you aware of a better way/place to execute final code once?

Thanks in advance for your help!


Abdallah

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech

_______________________________________________
grinder-use mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/grinder-use
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.