Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add restart tests #461

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
update after name change
  • Loading branch information
hendrikmuhs committed Dec 13, 2024
commit 7d36ad205aacc42cb5edd9afa3997277a388addc
8 changes: 4 additions & 4 deletions tests/test_restart.py
Original file line number Diff line number Diff line change
@@ -47,15 +47,15 @@ async def test_app_worker_restart(server_app, threading_mode):
@pytest.mark.asyncio
@pytest.mark.skipif(platform.system() == 'Windows', reason='SIGHUP/SIGSTOP not available on Windows')
@pytest.mark.parametrize('threading_mode', ['runtime', 'workers'])
async def test_app_worker_graceful_restart(server_app, threading_mode):
workers_graceful_timeout = 2
async def test_app_workers_kill_timeout(server_app, threading_mode):
workers_kill_timeout = 2
with tempfile.TemporaryDirectory() as tmp_dir:
pid_file_path = Path(tmp_dir, 'server.pid')
async with server_app(
interface='wsgi',
app='restart',
threading_mode=threading_mode,
extra_args={'workers_graceful_timeout': workers_graceful_timeout, 'pid_file': pid_file_path},
extra_args={'workers_kill_timeout': workers_kill_timeout, 'pid_file': pid_file_path},
) as port:
with pid_file_path.open('r') as pid_fd:
server_pid = int(pid_fd.read().strip())
@@ -73,7 +73,7 @@ async def test_app_worker_graceful_restart(server_app, threading_mode):
assert worker_pid_after_one_restart is not None

# wait until the worker_pid is gone
time.sleep(workers_graceful_timeout + 0.01)
time.sleep(workers_kill_timeout + 0.01)

# suspend the new worker process to simulate that it hangs
os.kill(worker_pid_after_one_restart, signal.SIGSTOP)
Loading