-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstaticmembers.py
More file actions
34 lines (27 loc) · 819 Bytes
/
staticmembers.py
File metadata and controls
34 lines (27 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
__author__ = 'Prateek'
class Connector(object):
max_connection = 5
counter = 0
def __str__(self):
return "{}:Connection id:{}".format(Connector.counter,self.connection_id)
def __init__(self,connection_id):
Connector.check_connection()
Connector.counter += 1
self.connection_id = connection_id
@staticmethod
def check_connection(self):
if Connector.counter == Connector.max_connection:
raise RuntimeError("Max connections reached")
if __name__ == '__main__':
conn = []
try:
for i in xrange(1,8):
conn.append(Connector("t"+str(i)))
#print conn.__str__()
except:
pass
finally:
for c in conn:
print c
print Connector.counter
print Connector.max_connection