avoid deadlock with cache lock

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2392 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2005-03-10 22:02:52 +00:00
parent 4d0d76446f
commit 4c248fce03

View file

@ -20,13 +20,10 @@ Url consumer class.
import sys
import time
try:
import threading
except ImportError:
import dummy_threading as threading
import linkcheck.threader
import linkcheck.log
import linkcheck.lock
import linkcheck.strformat
import linkcheck.checker.geoip
from urlbase import stderr
@ -52,9 +49,7 @@ def print_duration (duration):
print >> stderr, msg,
lock_klass = threading.RLock().__class__
class Consumer (lock_klass):
class Consumer (linkcheck.lock.AssertLock):
"""
Consume urls from the url queue in a thread-safe manner.
"""
@ -77,20 +72,6 @@ class Consumer (lock_klass):
self.warnings = False
self.logger_start_output()
def acquire (self):
"""
Acquire lock.
"""
linkcheck.log.debug(linkcheck.LOG_THREAD, "acquire data lock")
super(Consumer, self).acquire()
def release (self):
"""
Release lock.
"""
linkcheck.log.debug(linkcheck.LOG_THREAD, "release data lock")
super(Consumer, self).release()
def _set_threads (self, num):
"""
Set number of checker threads to start.
@ -190,13 +171,15 @@ class Consumer (lock_klass):
"""
Print check status looking at url queues.
"""
# avoid deadlock by requesting cache data before locking
tocheck = self.cache.incoming_len()
self.acquire()
try:
print >> stderr, _("Status:"),
active = self.threader.active_threads()
print_active(active)
print_links(self.linknumber)
print_tocheck(self.cache.incoming_len())
print_tocheck(tocheck)
print_duration(curtime - start_time)
print >> stderr
finally: