Changeset 4426aee7e00d…
Parent c2d6a90e94e4…
by
Changes to 2 files · Browse files at 4426aee7e00d Showing diff from parent c2d6a90e94e4 Diff from another changeset...
@@ -58,36 +58,44 @@ logmsg('Shell notified')
requests = Queue.Queue(0)
-_abort_request = r';:;:; Quit ;:;:;' # any invalid path would do
+
+def update(args):
+ batch = []
+ r = args[0]
+ print "got update request %s (first in batch)" % r
+ batch.append(r)
+ print "wait a bit for additional requests..."
+ time.sleep(0.2)
+ try:
+ while True:
+ r = requests.get_nowait()
+ print "got update request %s" % r
+ batch.append(r)
+ except Queue.Empty:
+ pass
+ msg = "processing batch with %i update requests"
+ print msg % len(batch)
+ update_batch(batch)
+
+def dispatch(req, cmd, args):
+ if cmd == 'update':
+ update(args)
+ else:
+ logmsg("Error: unknown request '%s'" % req)
class Updater(threading.Thread):
def run(self):
- n = 0
while True:
- batch = []
- r = requests.get()
- if r == _abort_request:
- logmsg('Updater thread quiting')
+ req = requests.get()
+ s = req.split('|')
+ cmd, args = s[0], s[1:]
+ if cmd is 'terminate':
+ logmsg('Updater thread terminating')
return
- print "got request %s (first in batch)" % r
- batch.append(r)
- print "wait a bit for additional requests..."
- 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 = "--- processing batch %i with %i requests ---"
- print msg % (n, len(batch))
- update_batch(batch)
+ dispatch(req, cmd, args)
Updater().start()
-
class PipeServer:
def __init__(self):
# Create an event which we will use to wait on.
@@ -103,9 +111,9 @@ self.overlapped.hEvent = win32event.CreateEvent(None,0,0,None)
def SvcStop(self):
- print 'PipeServer thread quiting'
+ print 'PipeServer thread terminating'
win32event.SetEvent(self.hWaitStop)
- requests.put(_abort_request)
+ requests.put('terminate')
def SvcDoRun(self):
# We create our named pipe.
|
@@ -42,11 +42,13 @@
BOOL fSuccess;
DWORD cbRead;
+
+ const std::string request = "update|" + path;
- TDEBUG_TRACE("Thgstatus::update(" << path << ") for " << pname);
+ TDEBUG_TRACE("Thgstatus::update: sending '" << request << "' to " << pname);
fSuccess = ::CallNamedPipeA(
- pname.c_str(), (void*)path.c_str(), path.size(), 0, 0, &cbRead,
+ pname.c_str(), (void*)request.c_str(), request.size(), 0, 0, &cbRead,
200 /* ms */
);
|
Loading...