Skip to content

Commit e04d024

Browse files
Hainishjeremyn
authored andcommitted
Ensure UrlComparisonThread ends when no tasks are remaining on taskQueue (fixes EFForg#6240) (EFForg#6692)
1 parent 7f5eb87 commit e04d024

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

test/rules/src/https_everywhere_checker/check_rules.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python
22

33
import binascii
44
import collections
@@ -83,7 +83,7 @@ def __init__(self, taskQueue, metric, thresholdDistance, autoDisable, resQueue):
8383
threading.Thread.__init__(self)
8484

8585
def run(self):
86-
while True:
86+
while not self.taskQueue.empty():
8787
try:
8888
self.processTask(self.taskQueue.get())
8989
self.taskQueue.task_done()
@@ -408,11 +408,6 @@ def cli():
408408
testedUrlPairCount = 0
409409
config.getboolean("debug", "exit_after_dump")
410410

411-
for i in range(threadCount):
412-
t = UrlComparisonThread(taskQueue, metric, thresholdDistance, autoDisable, resQueue)
413-
t.setDaemon(True)
414-
t.start()
415-
416411
# set of main pages to test
417412
mainPages = set(urlList)
418413
# If list of URLs to test/scan was not defined, use the test URL extraction
@@ -430,6 +425,12 @@ def cli():
430425
logging.debug("Skipping excluded URL %s", test.url)
431426
task = ComparisonTask(testUrls, fetcherPlain, fetcher, ruleset)
432427
taskQueue.put(task)
428+
429+
for i in range(threadCount):
430+
t = UrlComparisonThread(taskQueue, metric, thresholdDistance, autoDisable, resQueue)
431+
t.setDaemon(True)
432+
t.start()
433+
433434
taskQueue.join()
434435
logging.info("Finished in %.2f seconds. Loaded rulesets: %d, URL pairs: %d.",
435436
time.time() - startTime, len(xmlFnames), testedUrlPairCount)

0 commit comments

Comments
 (0)