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

rpcserver: use a worker thread

Changeset 84590784e03d

Parent d6f832a9a051

by Adrian Buehlmann

Changes to one file · Browse files at 84590784e03d Showing diff from parent d6f832a9a051 Diff from another changeset...

 
6
7
8
 
9
10
 
 
 
11
12
13
 
19
20
21
 
22
23
24
 
27
28
29
 
30
31
32
 
48
49
50
 
 
 
 
 
 
 
 
 
 
 
 
 
51
52
53
 
116
117
118
119
 
120
121
 
 
122
123
124
 
6
7
8
9
10
11
12
13
14
15
16
17
 
23
24
25
26
27
28
29
 
32
33
34
35
36
37
38
 
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 
135
136
137
 
138
139
 
140
141
142
143
144
@@ -6,8 +6,12 @@
 from mercurial import hg, cmdutil, util  from mercurial import repo as _repo  from thgutil import paths, shlib +  import sys  import time +import Queue +import threading +  import win32serviceutil  import win32service  import win32event @@ -19,6 +23,7 @@
 PIPENAME = "\\\\.\\pipe\\TortoiseHgRpcServer-bc0c27107423"  PIPEBUFSIZE = 4096   +  # FIXME: quick workaround traceback caused by missing "closed"  # attribute in win32trace.  from mercurial import ui @@ -27,6 +32,7 @@
  sys.stderr.write(str(a))  ui.ui.write_err = write_err   +  def update_thgstatus(path):   print "update_thgstatus(%s)" % path   root = paths.find_root(path) @@ -48,6 +54,19 @@
  print "updated repo %s" % r   print "update_thgstatus(%s) finished." % path   + +requests = Queue.Queue(0) + +class Updater(threading.Thread): + def run(self ): + while True: + r = requests.get() + if r is not None: + update_thgstatus(r) + +Updater().start() + +  class PipeServer:   def __init__(self):   # Create an event which we will use to wait on. @@ -116,9 +135,10 @@
  # or before reading the response.   # Thats OK - just get the next connection   continue - +   try: - update_thgstatus(data) + print "queueing request %s" % data + requests.put(data)   except SystemExit:   raise SystemExit # interrupted by thread2.terminate()   except: