Commit 4c3d08d
fix: prevent double pool initialization from concurrent callers
Wrap initialize() body in async with self._lock so that two
concurrent callers (e.g., via asyncio.gather on __aenter__) cannot
both pass the _initialized check and create 2*min_size connections.
Without the lock, the await points in _create_connection() and
_pool.put() allowed interleaving, causing the pool to exceed
max_size or even deadlock when min_size == max_size (the second
initializer blocks trying to put into a full queue).
Closes #082
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 860fa24 commit 4c3d08d
2 files changed
Lines changed: 36 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
76 | 105 | | |
77 | 106 | | |
78 | 107 | | |
| |||
0 commit comments