From 18747ee2b35e4a2f07579d32db890d32f3744286 Mon Sep 17 00:00:00 2001
From: RaNaN <Mast3rRaNaN@hotmail.de>
Date: Sat, 12 Oct 2013 18:06:09 +0200
Subject: small changes to dl algorithm

---
 pyload/network/Bucket.py | 29 ++---------------------------
 1 file changed, 2 insertions(+), 27 deletions(-)

(limited to 'pyload/network/Bucket.py')

diff --git a/pyload/network/Bucket.py b/pyload/network/Bucket.py
index db67faa4a..40d8c8071 100644
--- a/pyload/network/Bucket.py
+++ b/pyload/network/Bucket.py
@@ -1,24 +1,6 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
-"""
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 3 of the License,
-    or (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-    See the GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, see <http://www.gnu.org/licenses/>.
-    
-    @author: RaNaN
-"""
-
 from time import time
-from threading import Lock
 
 # 10kb minimum rate
 MIN_RATE = 10240
@@ -28,31 +10,24 @@ class Bucket:
         self.rate = 0 # bytes per second, maximum targeted throughput
         self.tokens = 0
         self.timestamp = time()
-        self.lock = Lock()
 
     def __nonzero__(self):
         return False if self.rate < MIN_RATE else True
 
     def setRate(self, rate):
-        self.lock.acquire()
         self.rate = int(rate)
-        self.lock.release()
 
     def consumed(self, amount):
         """ return the time the process has to sleep, after it consumed a specified amount """
         if self.rate < MIN_RATE: return 0 #May become unresponsive otherwise
-        self.lock.acquire()
 
         self.calc_tokens()
         self.tokens -= amount
 
         if self.tokens < 0:
-            time = -self.tokens/float(self.rate)
+            return -self.tokens/float(self.rate)
         else:
-            time = 0
-
-        self.lock.release()
-        return time
+            return 0
 
     def calc_tokens(self):
         if self.tokens < self.rate:
-- 
cgit v1.2.3