Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-87744: fix waitpid race while calling send_signal in asyncio#121126

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kumaraditya303 merged 6 commits intopython:mainfromkumaraditya303:main
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from1 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
NextNext commit
fix send_signal race
  • Loading branch information
@kumaraditya303
kumaraditya303 committedJun 28, 2024
commite0d6de50f22ffe093e47ee37dea93ed301d33f43
13 changes: 8 additions & 5 deletionsLib/asyncio/base_subprocess.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
import collections
import subprocess
import warnings
import os
import signal

from . import protocols
from . import transports
Expand DownExpand Up@@ -144,15 +146,16 @@ def _check_proc(self):

def send_signal(self, signal):
self._check_proc()
self._proc.send_signal(signal)
try:
os.kill(self._proc.pid, signal)
except ProcessLookupError:
pass

def terminate(self):
self._check_proc()
self._proc.terminate()
self.send_signal(signal.SIGTERM)

def kill(self):
self._check_proc()
self._proc.kill()
self.send_signal(signal.SIGKILL)

async def _connect_pipes(self, waiter):
try:
Expand Down
14 changes: 14 additions & 0 deletionsLib/test/test_asyncio/test_subprocess.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -864,6 +864,20 @@ async def main():

self.loop.run_until_complete(main())

def test_subprocess_send_signal_race(self):
# See https://github.com/python/cpython/issues/87744
async def main():
for _ in range(10):
proc = await asyncio.create_subprocess_exec('sleep', '0.1')
await asyncio.sleep(0.1)
try:
proc.send_signal(signal.SIGUSR1)
except ProcessLookupError:
pass
self.assertNotEqual(await proc.wait(), 255)

self.loop.run_until_complete(main())


if sys.platform != 'win32':
# Unix
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp