Ignore parameters for startFindOptional noparallel
This commit is contained in:
parent
fe19bd2fce
commit
d60785ee33
2 changed files with 8 additions and 5 deletions
|
@ -213,9 +213,8 @@ class WorkerManager(object):
|
||||||
return found
|
return found
|
||||||
|
|
||||||
# Start find peers for optional files
|
# Start find peers for optional files
|
||||||
@util.Noparallel(blocking=False)
|
@util.Noparallel(blocking=False, ignore_args=True)
|
||||||
def startFindOptional(self, reset_task=False, find_more=False):
|
def startFindOptional(self, reset_task=False, find_more=False, high_priority=False):
|
||||||
time.sleep(0.01) # Wait for more file requests
|
|
||||||
optional_tasks = [task for task in self.tasks if task["optional_hash_id"]]
|
optional_tasks = [task for task in self.tasks if task["optional_hash_id"]]
|
||||||
optional_hash_ids = set([task["optional_hash_id"] for task in optional_tasks])
|
optional_hash_ids = set([task["optional_hash_id"] for task in optional_tasks])
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
|
|
|
@ -4,13 +4,17 @@ import time
|
||||||
|
|
||||||
class Noparallel(object): # Only allow function running once in same time
|
class Noparallel(object): # Only allow function running once in same time
|
||||||
|
|
||||||
def __init__(self, blocking=True):
|
def __init__(self, blocking=True, ignore_args=False):
|
||||||
self.threads = {}
|
self.threads = {}
|
||||||
self.blocking = blocking # Blocking: Acts like normal function else thread returned
|
self.blocking = blocking # Blocking: Acts like normal function else thread returned
|
||||||
|
self.ignore_args = ignore_args
|
||||||
|
|
||||||
def __call__(self, func):
|
def __call__(self, func):
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
key = (func, tuple(args), str(kwargs)) # Unique key for function including parameters
|
if self.ignore_args:
|
||||||
|
key = func # Unique key only by function
|
||||||
|
else:
|
||||||
|
key = (func, tuple(args), str(kwargs)) # Unique key for function including parameters
|
||||||
if key in self.threads: # Thread already running (if using blocking mode)
|
if key in self.threads: # Thread already running (if using blocking mode)
|
||||||
thread = self.threads[key]
|
thread = self.threads[key]
|
||||||
if self.blocking:
|
if self.blocking:
|
||||||
|
|
Loading…
Reference in a new issue