Skip to content

Commit 345012c

Browse files
committed
Copilot + Noah review
1 parent 0c299e4 commit 345012c

3 files changed

Lines changed: 4 additions & 34 deletions

File tree

test/asynchronous/test_periodic_executor.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,6 @@ async def target():
6969
await executor.join(timeout=2)
7070
self.assertTrue(ran.is_set(), "target never ran")
7171

72-
async def test_target_exception_stops_executor(self):
73-
call_count = 0
74-
75-
async def target():
76-
nonlocal call_count
77-
call_count += 1
78-
raise RuntimeError("error")
79-
80-
executor = self._make_executor(target=target)
81-
executor.open()
82-
await executor.join(timeout=2)
83-
if executor._task is not None and executor._task.done():
84-
executor._task.exception()
85-
self.assertEqual(call_count, 1, "target should stop after exception")
86-
8772
async def test_skip_sleep_flag_skips_interval(self):
8873
call_times = []
8974

test/test_periodic_executor.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323

2424
sys.path[0:0] = [""]
2525

26-
from test import UnitTest, unittest
26+
from test.synchronous import UnitTest, unittest
2727

2828
from pymongo.periodic_executor import PeriodicExecutor
2929

30-
_IS_SYNC = True
30+
_IS_SYNC = False
3131

3232

33-
class TestPeriodicExecutor(UnitTest):
33+
class TestAsyncPeriodicExecutor(UnitTest):
3434
def _make_executor(self, interval=30.0, min_interval=0.01, target=None, name="test"):
3535
if target is None:
3636

@@ -69,21 +69,6 @@ def target():
6969
executor.join(timeout=2)
7070
self.assertTrue(ran.is_set(), "target never ran")
7171

72-
def test_target_exception_stops_executor(self):
73-
call_count = 0
74-
75-
def target():
76-
nonlocal call_count
77-
call_count += 1
78-
raise RuntimeError("error")
79-
80-
executor = self._make_executor(target=target)
81-
executor.open()
82-
executor.join(timeout=2)
83-
if executor._task is not None and executor._task.done():
84-
executor._task.exception()
85-
self.assertEqual(call_count, 1, "target should stop after exception")
86-
8772
def test_skip_sleep_flag_skips_interval(self):
8873
call_times = []
8974

tools/synchro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ def async_only_test(f: str) -> bool:
190190
"test_async_loop_safety.py",
191191
"test_async_contextvars_reset.py",
192192
"test_async_loop_unblocked.py",
193+
"test_async_periodic_executor.py",
193194
]
194195

195196

@@ -252,7 +253,6 @@ def async_only_test(f: str) -> bool:
252253
"test_monitoring.py",
253254
"test_mongos_load_balancing.py",
254255
"test_on_demand_csfle.py",
255-
"test_periodic_executor.py",
256256
"test_pooling.py",
257257
"test_raw_bson.py",
258258
"test_read_concern.py",

0 commit comments

Comments
 (0)