[Pywikipedia-l] SVN: [5378] trunk/pywikipedia/commonsdelinker

btongminh at svn.wikimedia.org btongminh at svn.wikimedia.org
Thu May 15 19:26:54 UTC 2008


Revision: 5378
Author:   btongminh
Date:     2008-05-15 19:26:54 +0000 (Thu, 15 May 2008)

Log Message:
-----------
Do a proper exit if we fail to connect

Modified Paths:
--------------
    trunk/pywikipedia/commonsdelinker/delinker.py
    trunk/pywikipedia/commonsdelinker/threadpool.py

Modified: trunk/pywikipedia/commonsdelinker/delinker.py
===================================================================
--- trunk/pywikipedia/commonsdelinker/delinker.py	2008-05-14 20:44:31 UTC (rev 5377)
+++ trunk/pywikipedia/commonsdelinker/delinker.py	2008-05-15 19:26:54 UTC (rev 5378)
@@ -445,7 +445,10 @@
 		self.site = CommonsDelinker.site
 		
 	def run(self):
-		self.connect()
+		try:
+			self.connect()
+		except:
+			return self.exit()
 		threadpool.Thread.run(self)
 		
 	def connect(self):

Modified: trunk/pywikipedia/commonsdelinker/threadpool.py
===================================================================
--- trunk/pywikipedia/commonsdelinker/threadpool.py	2008-05-14 20:44:31 UTC (rev 5377)
+++ trunk/pywikipedia/commonsdelinker/threadpool.py	2008-05-15 19:26:54 UTC (rev 5378)
@@ -126,9 +126,11 @@
 		self.pool.jobLock.acquire()
 		try:
 			self.quit = True
-			self.pool[id(self)].set()
-			del self.pool[id(self)]
-			self.pool.threads.remove(self)
+			if id(self) in self.pool:
+				self.pool[id(self)].set()
+				del self.pool[id(self)]
+			if self in self.pool.threads:
+				self.pool.threads.remove(self)
 		finally:
 			self.pool.jobLock.release()
 	





More information about the Pywikipedia-l mailing list