Skip to content

Commit 7cbdbef

Browse files
committed
PYTHON-5071 Fix PYTHON-5011 pypy workaround
1 parent c8d3afd commit 7cbdbef

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

test/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -941,9 +941,17 @@ def fail_point(self, command_args):
941941
try:
942942
yield
943943
finally:
944-
client_context.client.admin.command(
945-
"configureFailPoint", cmd_on["configureFailPoint"], mode="off"
946-
)
944+
try:
945+
client_context.client.admin.command(
946+
"configureFailPoint", cmd_on["configureFailPoint"], mode="off"
947+
)
948+
except pymongo.errors.ConnectionFailure:
949+
# Workaround PyPy bug described in PYTHON-5011.
950+
if not _IS_SYNC and "PyPy" in sys.version:
951+
client_context.client.admin.command(
952+
"configureFailPoint", cmd_on["configureFailPoint"], mode="off"
953+
)
954+
raise
947955

948956
@contextmanager
949957
def fork(

test/asynchronous/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -943,9 +943,17 @@ async def fail_point(self, command_args):
943943
try:
944944
yield
945945
finally:
946-
await async_client_context.client.admin.command(
947-
"configureFailPoint", cmd_on["configureFailPoint"], mode="off"
948-
)
946+
try:
947+
await async_client_context.client.admin.command(
948+
"configureFailPoint", cmd_on["configureFailPoint"], mode="off"
949+
)
950+
except pymongo.errors.ConnectionFailure:
951+
# Workaround PyPy bug described in PYTHON-5011.
952+
if not _IS_SYNC and "PyPy" in sys.version:
953+
await async_client_context.client.admin.command(
954+
"configureFailPoint", cmd_on["configureFailPoint"], mode="off"
955+
)
956+
raise
949957

950958
@contextmanager
951959
def fork(

0 commit comments

Comments
 (0)