summaryrefslogtreecommitdiff
path: root/pysnmp/nextid.py
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2016-04-01 23:06:11 +0200
committerIlya Etingof <etingof@gmail.com>2016-04-01 23:06:11 +0200
commitfbc9c2679bd04ea3241b294e78e1b66fe993d952 (patch)
treeab33c2701ccac4e7105eead5825d6545ea20e819 /pysnmp/nextid.py
parent020791a97232849c9504024834906dd4a4ffb36c (diff)
downloadpysnmp-git-fbc9c2679bd04ea3241b294e78e1b66fe993d952.tar.gz
pep8 reformatted
Diffstat (limited to 'pysnmp/nextid.py')
-rw-r--r--pysnmp/nextid.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/pysnmp/nextid.py b/pysnmp/nextid.py
index 3ac719d4..cd2fe20b 100644
--- a/pysnmp/nextid.py
+++ b/pysnmp/nextid.py
@@ -8,23 +8,25 @@ import random
random.seed()
+
class Integer:
"""Return a next value in a reasonably MT-safe manner"""
+
def __init__(self, maximum, increment=256):
self.__maximum = maximum
if increment >= maximum:
increment = maximum
self.__increment = increment
- self.__threshold = increment//2
+ self.__threshold = increment // 2
e = random.randrange(self.__maximum - self.__increment)
- self.__bank = list(range(e, e+self.__increment))
+ self.__bank = list(range(e, e + self.__increment))
def __repr__(self):
return '%s(%d, %d)' % (
self.__class__.__name__,
self.__maximum,
self.__increment
- )
+ )
def __call__(self):
v = self.__bank.pop(0)
@@ -33,8 +35,8 @@ class Integer:
else:
# this is MT-safe unless too many (~ increment/2) threads
# bump into this code simultaneously
- e = self.__bank[-1]+1
+ e = self.__bank[-1] + 1
if e > self.__maximum:
e = 0
- self.__bank.extend(range(e, e+self.__threshold))
+ self.__bank.extend(range(e, e + self.__threshold))
return v