Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

rpcserver: do updates in batches

Changeset c31cd0e444b2

Parent 848118a743fc

by Adrian Buehlmann

Changes to one file · Browse files at c31cd0e444b2 Showing diff from parent 848118a743fc Diff from another changeset...

 
34
35
36
37
38
39
40
41
42
43
44
45
46
 
52
53
54
55
56
57
58
59
60
61
 
62
 
63
64
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
67
68
 
34
35
36
 
37
38
39
40
 
 
41
42
43
 
49
50
51
 
52
53
54
55
56
57
58
59
60
61
 
 
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
@@ -34,13 +34,10 @@
     def update_thgstatus(path): - print "update_thgstatus(%s)" % path   root = paths.find_root(path)   _ui = ui.ui();   if root is not None:   shlib.update_thgstatus(_ui, root, wait=False) - time.sleep(2) - shlib.shell_notify([path])   print "updated repo %s" % root   else:   roots = [] @@ -52,17 +49,37 @@
  shlib.update_thgstatus(_ui, r, wait=False)   shlib.shell_notify([r])   print "updated repo %s" % r - print "update_thgstatus(%s) finished." % path      requests = Queue.Queue(0)    class Updater(threading.Thread):   def run(self ): + n = 0   while True: + batch = []   r = requests.get() - if r is not None: - update_thgstatus(r) + print "got request %s (new batch)" % r + batch.append(r) + print "waiting a bit" + time.sleep(0.2) + try: + while True: + r = requests.get_nowait() + print "got request %s" % r + batch.append(r) + except Queue.Empty: + pass + n += 1 + msg = "--- batch %i complete with %i requests" + msg += ", processing --" + print msg % (n, len(batch)) + if batch: + for r in batch: + update_thgstatus(r) + time.sleep(2) + shlib.shell_notify(batch) + print "shell notified"    Updater().start()