HTML parser queue flush fix

- the queue wasn't correctly flushed
This commit is contained in:
Peter Šurda 2016-11-14 20:19:26 +01:00
parent d35062b49c
commit 54e3465575
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -120,6 +120,13 @@ class SafeHTMLParser(HTMLParser):
parserProcess = multiprocessing.Process(target=regexpSubprocess, name="RegExParser", args=(parserInputQueue, parserOutputQueue)) parserProcess = multiprocessing.Process(target=regexpSubprocess, name="RegExParser", args=(parserInputQueue, parserOutputQueue))
parserProcess.start() parserProcess.start()
parserLock.release() parserLock.release()
# flush queue
try:
while True:
tmp = parserOutputQueue.get(False)
except Queue.Empty:
logger.debug("Parser queue flushed")
pass
parserInputQueue.put(tmp) parserInputQueue.put(tmp)
try: try:
tmp = parserOutputQueue.get(True, 1) tmp = parserOutputQueue.get(True, 1)
@ -130,14 +137,6 @@ class SafeHTMLParser(HTMLParser):
parserProcess = multiprocessing.Process(target=regexpSubprocess, name="RegExParser", args=(parserInputQueue, parserOutputQueue)) parserProcess = multiprocessing.Process(target=regexpSubprocess, name="RegExParser", args=(parserInputQueue, parserOutputQueue))
parserProcess.start() parserProcess.start()
parserLock.release() parserLock.release()
else:
# flush queue
try:
while True:
tmp = parserOutputQueue.get(False)
except Queue.Empty:
logger.debug("Parser queue flushed")
pass
self.raw += tmp self.raw += tmp