Skip to content

Commit f3ebf92

Browse files
authored
Merge branch 'master' into PYTHON-4493-prod
2 parents d8f4734 + 74b85d5 commit f3ebf92

File tree

8 files changed

+81
-37
lines changed

8 files changed

+81
-37
lines changed

.evergreen/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,10 +1430,10 @@ buildvariants:
14301430
- debian11-small
14311431
tasks:
14321432
- name: test-gcpkms
1433-
batchtime: 20160 # Use a batchtime of 14 days as suggested by the CSFLE test README
1433+
batchtime: 10080 # 7 days
14341434
- name: test-gcpkms-fail
14351435
- name: test-azurekms
1436-
batchtime: 20160 # Use a batchtime of 14 days as suggested by the CSFLE test README
1436+
batchtime: 10080 # 7 days
14371437
- name: test-azurekms-fail
14381438

14391439
- name: rhel8-test-lambda

.evergreen/generated_configs/variants.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ buildvariants:
823823
display_name: OCSP RHEL8 v4.4 Python3.9
824824
run_on:
825825
- rhel87-small
826-
batchtime: 20160
826+
batchtime: 10080
827827
expansions:
828828
AUTH: noauth
829829
SSL: ssl
@@ -836,7 +836,7 @@ buildvariants:
836836
display_name: OCSP RHEL8 v5.0 Python3.10
837837
run_on:
838838
- rhel87-small
839-
batchtime: 20160
839+
batchtime: 10080
840840
expansions:
841841
AUTH: noauth
842842
SSL: ssl
@@ -849,7 +849,7 @@ buildvariants:
849849
display_name: OCSP RHEL8 v6.0 Python3.11
850850
run_on:
851851
- rhel87-small
852-
batchtime: 20160
852+
batchtime: 10080
853853
expansions:
854854
AUTH: noauth
855855
SSL: ssl
@@ -862,7 +862,7 @@ buildvariants:
862862
display_name: OCSP RHEL8 v7.0 Python3.12
863863
run_on:
864864
- rhel87-small
865-
batchtime: 20160
865+
batchtime: 10080
866866
expansions:
867867
AUTH: noauth
868868
SSL: ssl
@@ -875,7 +875,7 @@ buildvariants:
875875
display_name: OCSP RHEL8 v8.0 Python3.13
876876
run_on:
877877
- rhel87-small
878-
batchtime: 20160
878+
batchtime: 10080
879879
expansions:
880880
AUTH: noauth
881881
SSL: ssl
@@ -888,7 +888,7 @@ buildvariants:
888888
display_name: OCSP RHEL8 rapid PyPy3.10
889889
run_on:
890890
- rhel87-small
891-
batchtime: 20160
891+
batchtime: 10080
892892
expansions:
893893
AUTH: noauth
894894
SSL: ssl
@@ -901,7 +901,7 @@ buildvariants:
901901
display_name: OCSP RHEL8 latest Python3.9
902902
run_on:
903903
- rhel87-small
904-
batchtime: 20160
904+
batchtime: 10080
905905
expansions:
906906
AUTH: noauth
907907
SSL: ssl
@@ -914,7 +914,7 @@ buildvariants:
914914
display_name: OCSP Win64 v4.4 Python3.9
915915
run_on:
916916
- windows-64-vsMulti-small
917-
batchtime: 20160
917+
batchtime: 10080
918918
expansions:
919919
AUTH: noauth
920920
SSL: ssl
@@ -927,7 +927,7 @@ buildvariants:
927927
display_name: OCSP Win64 v8.0 Python3.13
928928
run_on:
929929
- windows-64-vsMulti-small
930-
batchtime: 20160
930+
batchtime: 10080
931931
expansions:
932932
AUTH: noauth
933933
SSL: ssl
@@ -940,7 +940,7 @@ buildvariants:
940940
display_name: OCSP macOS v4.4 Python3.9
941941
run_on:
942942
- macos-14
943-
batchtime: 20160
943+
batchtime: 10080
944944
expansions:
945945
AUTH: noauth
946946
SSL: ssl
@@ -953,7 +953,7 @@ buildvariants:
953953
display_name: OCSP macOS v8.0 Python3.13
954954
run_on:
955955
- macos-14
956-
batchtime: 20160
956+
batchtime: 10080
957957
expansions:
958958
AUTH: noauth
959959
SSL: ssl
@@ -971,21 +971,21 @@ buildvariants:
971971
display_name: Auth OIDC Ubuntu-22
972972
run_on:
973973
- ubuntu2204-small
974-
batchtime: 20160
974+
batchtime: 10080
975975
- name: auth-oidc-macos
976976
tasks:
977977
- name: testoidc_task_group
978978
display_name: Auth OIDC macOS
979979
run_on:
980980
- macos-14
981-
batchtime: 20160
981+
batchtime: 10080
982982
- name: auth-oidc-win64
983983
tasks:
984984
- name: testoidc_task_group
985985
display_name: Auth OIDC Win64
986986
run_on:
987987
- windows-64-vsMulti-small
988-
batchtime: 20160
988+
batchtime: 10080
989989

990990
# Pyopenssl tests
991991
- name: pyopenssl-macos-python3.9

.evergreen/scripts/generate_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def generate_yaml(tasks=None, variants=None):
234234

235235
def create_ocsp_variants() -> list[BuildVariant]:
236236
variants = []
237-
batchtime = BATCHTIME_WEEK * 2
237+
batchtime = BATCHTIME_WEEK
238238
expansions = dict(AUTH="noauth", SSL="ssl", TOPOLOGY="server")
239239
base_display = "OCSP"
240240

@@ -674,7 +674,7 @@ def create_oidc_auth_variants():
674674
tasks,
675675
get_display_name("Auth OIDC", host),
676676
host=host,
677-
batchtime=BATCHTIME_WEEK * 2,
677+
batchtime=BATCHTIME_WEEK,
678678
)
679679
)
680680
return variants

.evergreen/scripts/setup-dev-env.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,18 @@ if [ -z "${PYMONGO_BIN_DIR:-}" ]; then
4343
export PATH="$PATH:$HOME/.local/bin"
4444
fi
4545

46+
# Set up venv, making sure c extensions build unless disabled.
47+
if [ -z "${NO_EXT:-}" ]; then
48+
export PYMONGO_C_EXT_MUST_BUILD=1
49+
fi
50+
# Set up visual studio env on Windows spawn hosts.
51+
if [ -f $HOME/.visualStudioEnv.sh ]; then
52+
set +u
53+
SSH_TTY=1 source $HOME/.visualStudioEnv.sh
54+
set -u
55+
fi
4656
uv sync --frozen
47-
uv run --frozen --with pip pip install -e .
57+
4858
echo "Setting up python environment... done."
4959

5060
# Ensure there is a pre-commit hook if there is a git checkout.

.github/workflows/dist.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ jobs:
3434
# Github Actions doesn't support pairing matrix values together, let's improvise
3535
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
3636
buildplat:
37-
- [ubuntu-20.04, "manylinux_x86_64", "cp3*-manylinux_x86_64"]
38-
- [ubuntu-20.04, "manylinux_aarch64", "cp3*-manylinux_aarch64"]
39-
- [ubuntu-20.04, "manylinux_ppc64le", "cp3*-manylinux_ppc64le"]
40-
- [ubuntu-20.04, "manylinux_s390x", "cp3*-manylinux_s390x"]
41-
- [ubuntu-20.04, "manylinux_i686", "cp3*-manylinux_i686"]
37+
- [ubuntu-latest, "manylinux_x86_64", "cp3*-manylinux_x86_64"]
38+
- [ubuntu-latest, "manylinux_aarch64", "cp3*-manylinux_aarch64"]
39+
- [ubuntu-latest, "manylinux_ppc64le", "cp3*-manylinux_ppc64le"]
40+
- [ubuntu-latest, "manylinux_s390x", "cp3*-manylinux_s390x"]
41+
- [ubuntu-latest, "manylinux_i686", "cp3*-manylinux_i686"]
4242
- [windows-2019, "win_amd6", "cp3*-win_amd64"]
4343
- [windows-2019, "win32", "cp3*-win32"]
4444
- [macos-14, "macos", "cp*-macosx_*"]

.github/workflows/test-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
runs-on: ${{ matrix.os }}
5555
strategy:
5656
matrix:
57-
os: [ubuntu-20.04]
57+
os: [ubuntu-latest]
5858
python-version: ["3.9", "pypy-3.10", "3.13", "3.13t"]
5959
name: CPython ${{ matrix.python-version }}-${{ matrix.os }}
6060
steps:

test/asynchronous/test_pooling.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,12 @@ async def run_mongo_thread(self):
123123

124124
self.state = "connection"
125125

126-
def __del__(self):
127-
if _IS_SYNC and self.sock:
128-
self.sock.close_conn(None)
126+
async def release_conn(self):
127+
if self.sock:
128+
await self.sock.unpin()
129+
self.sock = None
130+
return True
131+
return False
129132

130133

131134
async def run_cases(client, cases):
@@ -352,6 +355,10 @@ async def test_no_wait_queue_timeout(self):
352355

353356
self.assertEqual(t.state, "connection")
354357
self.assertEqual(t.sock, s1)
358+
# Cleanup
359+
await t.release_conn()
360+
await t.join()
361+
await pool.close()
355362

356363
async def test_checkout_more_than_max_pool_size(self):
357364
pool = await self.create_pool(max_pool_size=2)
@@ -364,16 +371,26 @@ async def test_checkout_more_than_max_pool_size(self):
364371
socks.append(sock)
365372

366373
tasks = []
367-
for _ in range(30):
374+
for _ in range(10):
368375
t = SocketGetter(self.c, pool)
369376
await t.start()
370377
tasks.append(t)
371378
await asyncio.sleep(1)
372379
for t in tasks:
373380
self.assertEqual(t.state, "get_socket")
374-
381+
# Cleanup
375382
for socket_info in socks:
376-
await socket_info.close_conn(None)
383+
await socket_info.unpin()
384+
while tasks:
385+
to_remove = []
386+
for t in tasks:
387+
if await t.release_conn():
388+
to_remove.append(t)
389+
await t.join()
390+
for t in to_remove:
391+
tasks.remove(t)
392+
await asyncio.sleep(0.05)
393+
await pool.close()
377394

378395
async def test_maxConnecting(self):
379396
client = await self.async_rs_or_single_client()

test/test_pooling.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,12 @@ def run_mongo_thread(self):
123123

124124
self.state = "connection"
125125

126-
def __del__(self):
127-
if _IS_SYNC and self.sock:
128-
self.sock.close_conn(None)
126+
def release_conn(self):
127+
if self.sock:
128+
self.sock.unpin()
129+
self.sock = None
130+
return True
131+
return False
129132

130133

131134
def run_cases(client, cases):
@@ -352,6 +355,10 @@ def test_no_wait_queue_timeout(self):
352355

353356
self.assertEqual(t.state, "connection")
354357
self.assertEqual(t.sock, s1)
358+
# Cleanup
359+
t.release_conn()
360+
t.join()
361+
pool.close()
355362

356363
def test_checkout_more_than_max_pool_size(self):
357364
pool = self.create_pool(max_pool_size=2)
@@ -364,16 +371,26 @@ def test_checkout_more_than_max_pool_size(self):
364371
socks.append(sock)
365372

366373
tasks = []
367-
for _ in range(30):
374+
for _ in range(10):
368375
t = SocketGetter(self.c, pool)
369376
t.start()
370377
tasks.append(t)
371378
time.sleep(1)
372379
for t in tasks:
373380
self.assertEqual(t.state, "get_socket")
374-
381+
# Cleanup
375382
for socket_info in socks:
376-
socket_info.close_conn(None)
383+
socket_info.unpin()
384+
while tasks:
385+
to_remove = []
386+
for t in tasks:
387+
if t.release_conn():
388+
to_remove.append(t)
389+
t.join()
390+
for t in to_remove:
391+
tasks.remove(t)
392+
time.sleep(0.05)
393+
pool.close()
377394

378395
def test_maxConnecting(self):
379396
client = self.rs_or_single_client()

0 commit comments

Comments
 (0)