From 047176bb3d537c09ed44e0f62b7f8f5889ab90d7 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Wed, 10 Mar 2010 09:22:27 +0100 Subject: Improvement of the security (test URLs,etc.). Added mutex. --- utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'utils.py') diff --git a/utils.py b/utils.py index 7b1d7285..1412a50a 100644 --- a/utils.py +++ b/utils.py @@ -2,8 +2,8 @@ #-*- coding: utf-8 -*- __author__ = "Cedric Bonhomme" -__version__ = "$Revision: 0.2 $" -__date__ = "$Date: 2010/03/07 $" +__version__ = "$Revision: 0.3 $" +__date__ = "$Date: 2010/03/10 $" __copyright__ = "Copyright (c) 2010 Cedric Bonhomme" __license__ = "GPLv3" @@ -30,6 +30,9 @@ try: except: IMPORT_ERROR.append("oice") +import threading +LOCKER = threading.Lock() + def detect_language(text): """ Detect the language of a text. @@ -140,6 +143,7 @@ def load_feed(): """ Load feeds and articles in a dictionary. """ + LOCKER.acquire() list_of_feeds = None list_of_articles = None try: @@ -197,6 +201,6 @@ def load_feed(): feed[3], feed[0], feed[2], feed[1] \ ) c.close() - + LOCKER.release() return (articles, feeds) return (articles, feeds) \ No newline at end of file -- cgit