Skip to content

Commit 9255bf9

Browse files
authored
Revert "PYTHON-5594 Make process shutdown more robust (#322)"
This reverts commit 570a56f.
1 parent 570a56f commit 9255bf9

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

mongo_orchestration/daemon.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import sys
2323
import time
2424

25-
from signal import SIGTERM, SIGKILL
25+
from signal import SIGTERM
2626

2727
DEVNULL = open(os.devnull, 'r+b')
2828

@@ -174,15 +174,8 @@ def stop(self):
174174
# Try killing the daemon process
175175
try:
176176
os.kill(pid, SIGTERM)
177-
t0 = time.time()
178177
while is_unix_process_running(pid):
179178
time.sleep(0.25)
180-
# After 5 seconds resend a SIGTERM to the process.
181-
if time.time() - t0 > 5:
182-
os.kill(pid, SIGTERM)
183-
# After 10 seconds send a SIGKILL to the process.
184-
if time.time() - t0 > 10:
185-
os.kill(pid, SIGKILL)
186179
except OSError as err:
187180
if err.errno == errno.ESRCH:
188181
if os.path.exists(self.pidfile):
@@ -216,3 +209,4 @@ def is_unix_process_running(pid):
216209
else:
217210
raise err
218211
return True
212+

tests/test_launch.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ def run(cmd, **kwargs):
2626
if proc.returncode != 0:
2727
raise RuntimeError('Process failed!')
2828

29+
30+
def stop():
31+
pid = Path("server.pid").read_text().strip()
32+
os.kill(int(pid), signal.SIGTERM)
33+
Path("server.pid").unlink()
34+
2935
class TestLaunch(unittest.TestCase):
3036

3137
def test_launch_single(self):
@@ -37,7 +43,9 @@ def test_launch_single(self):
3743
proc.send('q\n')
3844
proc.wait()
3945
self.assertEqual(proc.exitstatus, 0)
40-
run('mongo-orchestration stop')
46+
# TODO: https://jira.mongodb.org/browse/PYTHON-5594
47+
# run('mongo-orchestration stop')
48+
stop()
4149

4250
def test_launch_replica_set(self):
4351
if os.name != 'posix':
@@ -48,7 +56,9 @@ def test_launch_replica_set(self):
4856
proc.send('q\n')
4957
proc.wait()
5058
self.assertEqual(proc.exitstatus, 0)
51-
run('mongo-orchestration stop')
59+
# TODO: https://jira.mongodb.org/browse/PYTHON-5594
60+
# run('mongo-orchestration stop')
61+
stop()
5262

5363

5464
def test_launch_sharded(self):
@@ -60,4 +70,6 @@ def test_launch_sharded(self):
6070
proc.send('q\n')
6171
proc.wait()
6272
self.assertEqual(proc.exitstatus, 0)
63-
run('mongo-orchestration stop')
73+
# TODO: https://jira.mongodb.org/browse/PYTHON-5594
74+
# run('mongo-orchestration stop')
75+
stop()

0 commit comments

Comments
 (0)