mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-06 12:41:30 +00:00
some update
This commit is contained in:
@@ -2,22 +2,26 @@
|
||||
|
||||
import threading
|
||||
|
||||
def timeout(func, args=(), kwargs={}, timeout_duration=1, default=None):
|
||||
def timeout(func, args=(), kwargs={}, duration=1, default=None):
|
||||
class InterruptableThread(threading.Thread):
|
||||
def __init__(self):
|
||||
threading.Thread.__init__(self)
|
||||
self.exceeded = False
|
||||
self.exceptionMsg = None
|
||||
self.result = None
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
self.result = func(*args, **kwargs)
|
||||
except:
|
||||
except Exception, msg:
|
||||
self.exceptionMsg = msg
|
||||
self.result = default
|
||||
|
||||
thread = InterruptableThread()
|
||||
thread.start()
|
||||
thread.join(timeout_duration)
|
||||
if thread.isAlive():
|
||||
thread.join(duration)
|
||||
self.exceeded = thread.isAlive()
|
||||
if self.exceeded:
|
||||
return default
|
||||
else:
|
||||
return thread.result
|
||||
|
||||
Reference in New Issue
Block a user