Minor refactoring

This commit is contained in:
Miroslav Stampar
2012-12-07 11:54:34 +01:00
parent fbaeecdaf9
commit 75e6d77fbc
3 changed files with 7 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ See the file 'doc/COPYING' for copying permission
import threading
from lib.core.data import logger
from lib.core.enums import CUSTOM_LOGGING
def timeout(func, args=(), kwargs={}, duration=1, default=None):
class InterruptableThread(threading.Thread):
@@ -19,7 +20,7 @@ def timeout(func, args=(), kwargs={}, duration=1, default=None):
try:
self.result = func(*args, **kwargs)
except Exception, msg:
logger.log(7, msg)
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, msg)
self.result = default
thread = InterruptableThread()