Skip to content

Commit a97a291

Browse files
committed
reduced lock size
1 parent a6ed286 commit a97a291

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

app.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,18 @@ def __createConnection(self, idx):
8585

8686
def __getConnection(self):
8787
self.__lock.acquire()
88-
idx = self.__conn_index + 1
89-
90-
if idx > 9:
91-
idx = 0
92-
88+
idx = self.__conn_index + 1
89+
if idx > 9: idx = 0
90+
self.__conn_index = idx
91+
self.__lock.release()
92+
9393
if not idx in self.__conn_dict.keys():
9494
application_name = ";APP={0}-{1}".format(socket.gethostname(), idx)
9595
conn = pyodbc.connect(os.environ['SQLAZURECONNSTR_WWIF'] + application_name)
9696
self.__conn_dict.update( { idx: conn } )
9797
else:
9898
conn = self.__conn_dict[idx]
9999

100-
self.__conn_index = idx
101-
self.__lock.release()
102-
103100
return (idx, conn)
104101

105102
def __removeConnection(self, idx):

0 commit comments

Comments
 (0)