subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r1296023 - /subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py
Date Fri, 02 Mar 2012 01:40:07 GMT
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):



Mime
View raw message