Parcourir la source

Some bugfixes.

tags/v0.2
Ben Kurtovic il y a 10 ans
Parent
révision
7c0e98596c
2 fichiers modifiés avec 9 ajouts et 8 suppressions
  1. +4
    -3
      earwigbot/wiki/copyvios/__init__.py
  2. +5
    -5
      earwigbot/wiki/copyvios/workers.py

+ 4
- 3
earwigbot/wiki/copyvios/__init__.py Voir le fichier

@@ -171,8 +171,9 @@ class CopyvioMixIn(object):
self._logger, self._addheaders, max_time)
workspace.enqueue([url])
workspace.wait()
url, conf, chains = workspace.best
result = CopyvioCheckResult(conf >= min_confidence, conf, url, 0,
time() - start_time, article, chains)
best = workspace.best
result = CopyvioCheckResult(best.confidence >= min_confidence,
best.confidence, best.url, 0,
time() - start_time, article, best.chains)
self._logger.info(result.get_log_message(self.title))
return result

+ 5
- 5
earwigbot/wiki/copyvios/workers.py Voir le fichier

@@ -39,8 +39,8 @@ tldextract = importer.new("tldextract")
__all__ = ["globalize", "localize", "CopyvioWorkspace"]

_is_globalized = False
_global_workers = []
_global_queues = None
_global_workers = []

def globalize(num_workers=8):
"""Cause all copyvio checks to be done by one global set of workers.
@@ -73,14 +73,14 @@ def localize():
This function is not thread-safe and should only be called when no checks
are being done.
"""
global _is_globalized, _global_queues
global _is_globalized, _global_queues, _global_workers
if not _is_globalized:
return

for i in xrange(len(_global_workers)):
_global_queues.unassigned.put((StopIteration, None))
_global_queues = None
_global_workers = None
_global_workers = []
_is_globalized = False


@@ -252,7 +252,7 @@ class CopyvioWorkspace(object):

def __init__(self, article, min_confidence, until, logger, headers,
url_timeout=5, num_workers=8):
self.best = _CopyvioSource(self, None)
self.best = _CopyvioSource(self, None, None)
self.sources = []

self._article = article
@@ -263,7 +263,7 @@ class CopyvioWorkspace(object):
self._is_finished = False
self._compare_lock = Lock()
self._source_args = {"workspace": self, "headers": headers,
"timeout": url_timeout)
"timeout": url_timeout}

if _is_globalized:
self._queues = _global_queues


Chargement…
Annuler
Enregistrer