Skip to content

Commit

Permalink
Register a zope.testing.cleanup.addCleanUp function to stop all pur…
Browse files Browse the repository at this point in the history
…ge threads. Also make the default purger available as a module global, so the cleanup function can get to it after the ZCA has been torn down.

svn path=/plone.cachepurging/trunk/; revision=49919
  • Loading branch information
hannosch committed May 21, 2011
1 parent 0c066bd commit f2a9c61
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Changelog
1.0.1 - Unreleased
------------------

- Register a `zope.testing.cleanup.addCleanUp` function to stop all purge
threads. Also make the default purger available as a module global, so the
cleanup function can get to it after the ZCA has been torn down.
[hannosch]

- Register an atexit handler to stop the purge thread on process shutdown.
[hannosch]

Expand Down
2 changes: 1 addition & 1 deletion plone/cachepurging/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<subscriber handler=".hooks.purge" />

<!-- Purge queue -->
<utility factory=".purger.DefaultPurger" />
<utility component=".purger.DEFAULT_PURGER" />

<!-- Make sure we can annotate the request -->
<class class="ZPublisher.BaseRequest.BaseRequest">
Expand Down
11 changes: 11 additions & 0 deletions plone/cachepurging/purger.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,14 @@ def getConnection(self, url):
break
time.sleep(1)
return None # must be stopping!

DEFAULT_PURGER = DefaultPurger()


def stopThreads():
purger = DEFAULT_PURGER
purger.stopThreads()

from zope.testing.cleanup import addCleanUp
addCleanUp(stopThreads)
del addCleanUp

0 comments on commit f2a9c61

Please sign in to comment.