Skip to content

Commit 9fcdcbd

Browse files
committed
Revert "Fix scheduler.once() running multiple times (#231)"
This reverts commit d4f78c5. The same bug exists not only in schedule.once() but also schedule.every() so a better fix is necessary.
1 parent a1137ca commit 9fcdcbd

File tree

2 files changed

+0
-26
lines changed

2 files changed

+0
-26
lines changed

mmpy_bot/scheduler.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,8 @@ def set_next_run(self, next_time: datetime):
1818
raise AssertionError("The next_time parameter should be a datetime object.")
1919
self.at_time = next_time
2020
self.next_run = next_time
21-
self.should_run = True
22-
23-
@property
24-
def should_run(self):
25-
return self._keep_running and super().should_run
26-
27-
@should_run.setter
28-
def should_run(self, value):
29-
self._keep_running = value
3021

3122
def run(self):
32-
# This prevents the job from running more than once
33-
self.should_run = False
34-
3523
super().run()
3624
return schedule.CancelJob()
3725

tests/unit_tests/scheduler_test.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from datetime import datetime
44
from pathlib import Path
55
from typing import Dict
6-
from unittest.mock import Mock
76

87
import pytest
98

@@ -32,19 +31,6 @@ def job(path: str):
3231
assert float(file.readline()) - 2 == pytest.approx(start, abs=0.3)
3332

3433

35-
def test_once_single_call():
36-
mock = Mock()
37-
mock.side_effect = lambda: time.sleep(0.2)
38-
39-
schedule.once().do(mock)
40-
41-
for _ in range(10):
42-
schedule.run_pending()
43-
time.sleep(0.05)
44-
45-
mock.assert_called_once()
46-
47-
4834
def test_recurring_thread():
4935
def job(modifiable_arg: Dict):
5036
# Modify the variable, which should be shared with the main thread.

0 commit comments

Comments
 (0)