Faidon has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/62418


Change subject: swiftrepl: add a -o (once) option
......................................................................

swiftrepl: add a -o (once) option

Add a -o (once) option that doesn't loop over containers forever but
finishes up and moves to the next container when it's done. Especially
helpful with sync_deletes().

Also, join all threads in the main thread instead of while True:
sleep(10). This in combination with the above means that swiftrepl
actually exits when done with all containers.

Change-Id: I265e81c341568373d952e69804cb7611928bd6d0
---
M swiftrepl/swiftrepl.py
1 file changed, 12 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/software 
refs/changes/18/62418/1

diff --git a/swiftrepl/swiftrepl.py b/swiftrepl/swiftrepl.py
index a3c323d..aeacf12 100644
--- a/swiftrepl/swiftrepl.py
+++ b/swiftrepl/swiftrepl.py
@@ -390,16 +390,22 @@
 def replicator_thread(*args, **kwargs):
        while True:
                try:
-                       container = containers.popleft()
+                       try:
+                               container = containers.popleft()
+                       except IndexError:
+                               break
+
                        if '-d' in sys.argv:
                                sync_deletes(container, kwargs['srcconnpool'], 
kwargs['dstconnpool'])
                        else:
                                sync_container(container, 
kwargs['srcconnpool'], kwargs['dstconnpool'])
+
+                       if '-o' not in sys.argv: # once
+                               containers.append(container)
                except Exception as e:
                        print >> sys.stderr, e, traceback.format_exc()
                        print >> sys.stderr, "Abandoning container %s for now" 
% container
                        time.sleep(10);
-               finally:
                        containers.append(container)
 
 
@@ -431,5 +437,7 @@
                t.daemon = True
                t.start()
        
-       while True:
-               time.sleep(10)
+       for thread in threading.enumerate():
+               if thread is threading.currentThread():
+                       continue
+               thread.join()

-- 
To view, visit https://gerrit.wikimedia.org/r/62418
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I265e81c341568373d952e69804cb7611928bd6d0
Gerrit-PatchSet: 1
Gerrit-Project: operations/software
Gerrit-Branch: master
Gerrit-Owner: Faidon <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to