mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-23 10:03:47 +03:00
b6da946883
Fixed also -d verbose output.
35 lines
802 B
Python
35 lines
802 B
Python
#!/usr/bin/env python
|
|
|
|
"""
|
|
$Id$
|
|
|
|
Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/)
|
|
See the file 'doc/COPYING' for copying permission
|
|
"""
|
|
|
|
import threading
|
|
|
|
from lib.core.data import logger
|
|
|
|
def timeout(func, args=(), kwargs={}, duration=1, default=None):
|
|
class InterruptableThread(threading.Thread):
|
|
def __init__(self):
|
|
threading.Thread.__init__(self)
|
|
self.result = None
|
|
|
|
def run(self):
|
|
try:
|
|
self.result = func(*args, **kwargs)
|
|
except Exception, msg:
|
|
logger.log(7, msg)
|
|
self.result = default
|
|
|
|
thread = InterruptableThread()
|
|
thread.start()
|
|
thread.join(duration)
|
|
|
|
if thread.isAlive():
|
|
return default
|
|
else:
|
|
return thread.result
|