You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by gs...@apache.org on 2012/03/02 02:40:07 UTC
svn commit: r1296023 -
/subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py
Author: gstein
Date: Fri Mar 2 01:40:06 2012
New Revision: 1296023
URL: http://svn.apache.org/viewvc?rev=1296023&view=rev
Log:
Delay the thread-start in case the process needs to fork/daemonize
itself first.
* tools/server-side/svnpubsub/svnwcsub.py:
(BackgroundWorker.__init__): initialize a flag indicating whether
we've started ourself or not.
(BackgroundWorker.add_work): possibly start when work arrives
Modified:
subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py
Modified: subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py?rev=1296023&r1=1296022&r2=1296023&view=diff
==============================================================================
--- subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py (original)
+++ subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py Fri Mar 2 01:40:06 2012
@@ -341,6 +341,8 @@ class BackgroundWorker(threading.Thread)
self.env = env
self.q = Queue.Queue()
+ self.has_started = False
+
def run(self):
while True:
if self.q.qsize() > BACKLOG_TOO_HIGH:
@@ -362,6 +364,12 @@ class BackgroundWorker(threading.Thread)
self.q.task_done()
def add_work(self, operation, wc):
+ # Start the thread when work first arrives. Thread-start needs to
+ # be delayed in case the process forks itself to become a daemon.
+ if not self.has_started:
+ self.start()
+ self.has_started = True
+
self.q.put((operation, wc))
def _update(self, wc):