File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
mongodb_consistent_backup/Oplog/Resolver Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 44# noinspection PyPackageRequirements
55from bson .timestamp import Timestamp
66from copy_reg import pickle
7- from multiprocessing import Pool
7+ from multiprocessing import Pool , TimeoutError
88from time import sleep
99from types import MethodType
1010
@@ -70,20 +70,24 @@ def done(self, done_uri):
7070 else :
7171 raise OperationError ("Unexpected response from resolver thread: %s" % done_uri )
7272
73- def wait (self ):
73+ def wait (self , max_wait_secs = 6 * 3600 ):
7474 if len (self ._pooled ) > 0 :
75+ waited_secs = 0
7576 self ._pool .close ()
7677 while len (self ._pooled ):
7778 logging .debug ("Waiting for %i oplog resolver thread(s) to stop" % len (self ._pooled ))
7879 try :
7980 for thread_name in self ._pooled :
8081 thread = self ._results [thread_name ]
81- thread .get (1 )
82- sleep (2 )
83- except Exception , e :
84- raise e
82+ thread .get (2 )
83+ except TimeoutError :
84+ if waited_secs < max_wait_secs :
85+ waited_secs += 2
86+ continue
87+ else :
88+ raise OperationError ("Waited more than %i seconds for Oplog resolver! I will assume there is a problem and exit" )
8589 self ._pool .terminate ()
86- logging .debug ("Stopped all oplog resolve threads" )
90+ logging .debug ("Stopped all oplog resolver threads" )
8791 self .stopped = True
8892 self .running = False
8993
You can’t perform that action at this time.
0 commit comments