Skip to content

Commit bb065c8

Browse files
authored
refactor: check connection connected before append to free list (#4)
2 parents 9b2fdbe + c2aca76 commit bb065c8

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ name: ci
22
on:
33
push:
44
branches-ignore:
5-
- master
5+
- main
66
pull_request:
77
branches-ignore:
88
- master
99
jobs:
1010
test:
11+
if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.base.repo.full_name == github.repository) }}
1112
runs-on: ubuntu-22.04
1213
services:
1314
mssql:
@@ -57,6 +58,7 @@ jobs:
5758
COVERALLS_PARALLEL: true
5859

5960
coveralls:
61+
if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.base.repo.full_name == github.repository) }}
6062
name: Finish Coveralls
6163
needs: test
6264
runs-on: ubuntu-22.04

asyncodbc/pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ async def release(self, conn):
192192
self._terminated.remove(conn)
193193
return
194194
self._used.remove(conn)
195-
if not conn.closed:
195+
if conn.connected and not conn.closed:
196196
if self._closing:
197197
await conn.close()
198198
else:

tests/test_pool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ async def test_release_closed(pool):
6060
assert 0 == pool.freesize
6161
await conn.close()
6262
await pool.release(conn)
63-
assert 1 == pool.freesize
63+
assert 0 == pool.freesize
6464
assert not pool._used
65-
assert 1 == pool.size
65+
assert 0 == pool.size
6666

6767
conn2 = await pool.acquire()
6868
assert 0 == pool.freesize

0 commit comments

Comments
 (0)