atExit tooling

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

atExit tooling

Darren Ball
Hi All,

I recently attempted to add a cleanup of my test on exit.

I added the following:

class TestRunner:
    def __init__(self):
        log("Worker process initializing, instrumenting")
        atexit.register(cleanup)  <-----

This is now executed by each thread launched by the agent.  I don't want that, as this cleanup is iterating a deque for cleanup.


Is there a correct way to tool this so that it only happens once?

Any help is great help!

Thanks.

Darren

------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
grinder-use mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/grinder-use
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: atExit tooling

Darren Ball
Looks like there is:
def __del__(self):
        grinder.logger.info("Thread shutting down")


This is thread specific. If I want to run this once, non-thread specific, can I just register atExit outside of TestRunner?

Thanks.

Darren

On Thu, Sep 24, 2015 at 12:17 PM, Darren Ball <[hidden email]> wrote:
Hi All,

I recently attempted to add a cleanup of my test on exit.

I added the following:

class TestRunner:
    def __init__(self):
        log("Worker process initializing, instrumenting")
        atexit.register(cleanup)  <-----

This is now executed by each thread launched by the agent.  I don't want that, as this cleanup is iterating a deque for cleanup.


Is there a correct way to tool this so that it only happens once?

Any help is great help!

Thanks.

Darren


------------------------------------------------------------------------------

_______________________________________________
grinder-use mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/grinder-use
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: atExit tooling

Philip Aston-2
Yes, that should be fine.

On 24/09/15 19:50, Darren Ball wrote:

> Looks like there is:
> |def| |__del__(||self||):|
> |        ||grinder.logger.info <http://grinder.logger.info>(||"Thread
> shutting down"||)|
> ||
> ||
> |This is thread specific. If I want to run this once, non-thread
> specific, can I just register atExit outside of TestRunner?|
> ||
> |Thanks.|
> ||
> |Darren|
>
> On Thu, Sep 24, 2015 at 12:17 PM, Darren Ball <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi All,
>
>     I recently attempted to add a cleanup of my test on exit.
>
>     I added the following:
>
>     class TestRunner:
>         def __init__(self):
>             log("Worker process initializing, instrumenting")
>             atexit.register(cleanup)  <-----
>
>     This is now executed by each thread launched by the agent.  I
>     don't want that, as this cleanup is iterating a deque for cleanup.
>
>
>     Is there a correct way to tool this so that it only happens once?
>
>     Any help is great help!
>
>     Thanks.
>
>     Darren
>
>
>
>
> ------------------------------------------------------------------------------
>
>
> _______________________________________________
> grinder-use mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/grinder-use


------------------------------------------------------------------------------
_______________________________________________
grinder-use mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/grinder-use
Loading...