Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
7b5856e7
Unverified
Kaydet (Commit)
7b5856e7
authored
Haz 27, 2018
tarafından
Victor Stinner
Kaydeden (comit)
GitHub
Haz 27, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Revert "bpo-33929: multiprocessing: fix handle leak on race condition (GH-7921)" (GH-7963)
This reverts commit
8b1ebcd7
.
üst
8b1ebcd7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
34 deletions
+6
-34
popen_spawn_win32.py
Lib/multiprocessing/popen_spawn_win32.py
+2
-13
reduction.py
Lib/multiprocessing/reduction.py
+3
-7
spawn.py
Lib/multiprocessing/spawn.py
+1
-9
2018-06-26-02-09-18.bpo-33929.OcCLah.rst
...S.d/next/Library/2018-06-26-02-09-18.bpo-33929.OcCLah.rst
+0
-5
No files found.
Lib/multiprocessing/popen_spawn_win32.py
Dosyayı görüntüle @
7b5856e7
...
@@ -18,12 +18,6 @@ TERMINATE = 0x10000
...
@@ -18,12 +18,6 @@ TERMINATE = 0x10000
WINEXE
=
(
sys
.
platform
==
'win32'
and
getattr
(
sys
,
'frozen'
,
False
))
WINEXE
=
(
sys
.
platform
==
'win32'
and
getattr
(
sys
,
'frozen'
,
False
))
WINSERVICE
=
sys
.
executable
.
lower
()
.
endswith
(
"pythonservice.exe"
)
WINSERVICE
=
sys
.
executable
.
lower
()
.
endswith
(
"pythonservice.exe"
)
def
_close_handles
(
*
handles
):
for
handle
in
handles
:
_winapi
.
CloseHandle
(
handle
)
#
#
# We define a Popen class similar to the one from subprocess, but
# We define a Popen class similar to the one from subprocess, but
# whose constructor takes a process object as its argument.
# whose constructor takes a process object as its argument.
...
@@ -38,12 +32,8 @@ class Popen(object):
...
@@ -38,12 +32,8 @@ class Popen(object):
def
__init__
(
self
,
process_obj
):
def
__init__
(
self
,
process_obj
):
prep_data
=
spawn
.
get_preparation_data
(
process_obj
.
_name
)
prep_data
=
spawn
.
get_preparation_data
(
process_obj
.
_name
)
# read end of pipe will be
duplicated
by the child process
# read end of pipe will be
"stolen"
by the child process
# -- see spawn_main() in spawn.py.
# -- see spawn_main() in spawn.py.
#
# bpo-33929: Previously, the read end of pipe was "stolen" by the child
# process, but it leaked a handle if the child process had been
# terminated before it could steal the handle from the parent process.
rhandle
,
whandle
=
_winapi
.
CreatePipe
(
None
,
0
)
rhandle
,
whandle
=
_winapi
.
CreatePipe
(
None
,
0
)
wfd
=
msvcrt
.
open_osfhandle
(
whandle
,
0
)
wfd
=
msvcrt
.
open_osfhandle
(
whandle
,
0
)
cmd
=
spawn
.
get_command_line
(
parent_pid
=
os
.
getpid
(),
cmd
=
spawn
.
get_command_line
(
parent_pid
=
os
.
getpid
(),
...
@@ -66,8 +56,7 @@ class Popen(object):
...
@@ -66,8 +56,7 @@ class Popen(object):
self
.
returncode
=
None
self
.
returncode
=
None
self
.
_handle
=
hp
self
.
_handle
=
hp
self
.
sentinel
=
int
(
hp
)
self
.
sentinel
=
int
(
hp
)
self
.
finalizer
=
util
.
Finalize
(
self
,
_close_handles
,
self
.
finalizer
=
util
.
Finalize
(
self
,
_winapi
.
CloseHandle
,
(
self
.
sentinel
,))
(
self
.
sentinel
,
int
(
rhandle
)))
# send information to child
# send information to child
set_spawning_popen
(
self
)
set_spawning_popen
(
self
)
...
...
Lib/multiprocessing/reduction.py
Dosyayı görüntüle @
7b5856e7
...
@@ -68,16 +68,12 @@ if sys.platform == 'win32':
...
@@ -68,16 +68,12 @@ if sys.platform == 'win32':
__all__
+=
[
'DupHandle'
,
'duplicate'
,
'steal_handle'
]
__all__
+=
[
'DupHandle'
,
'duplicate'
,
'steal_handle'
]
import
_winapi
import
_winapi
def
duplicate
(
handle
,
target_process
=
None
,
inheritable
=
False
,
def
duplicate
(
handle
,
target_process
=
None
,
inheritable
=
False
):
*
,
source_process
=
None
):
'''Duplicate a handle. (target_process is a handle not a pid!)'''
'''Duplicate a handle. (target_process is a handle not a pid!)'''
current_process
=
_winapi
.
GetCurrentProcess
()
if
source_process
is
None
:
source_process
=
current_process
if
target_process
is
None
:
if
target_process
is
None
:
target_process
=
current_process
target_process
=
_winapi
.
GetCurrentProcess
()
return
_winapi
.
DuplicateHandle
(
return
_winapi
.
DuplicateHandle
(
source_process
,
handle
,
target_process
,
_winapi
.
GetCurrentProcess
()
,
handle
,
target_process
,
0
,
inheritable
,
_winapi
.
DUPLICATE_SAME_ACCESS
)
0
,
inheritable
,
_winapi
.
DUPLICATE_SAME_ACCESS
)
def
steal_handle
(
source_pid
,
handle
):
def
steal_handle
(
source_pid
,
handle
):
...
...
Lib/multiprocessing/spawn.py
Dosyayı görüntüle @
7b5856e7
...
@@ -96,15 +96,7 @@ def spawn_main(pipe_handle, parent_pid=None, tracker_fd=None):
...
@@ -96,15 +96,7 @@ def spawn_main(pipe_handle, parent_pid=None, tracker_fd=None):
assert
is_forking
(
sys
.
argv
),
"Not forking"
assert
is_forking
(
sys
.
argv
),
"Not forking"
if
sys
.
platform
==
'win32'
:
if
sys
.
platform
==
'win32'
:
import
msvcrt
import
msvcrt
import
_winapi
new_handle
=
reduction
.
steal_handle
(
parent_pid
,
pipe_handle
)
if
parent_pid
is
not
None
:
source_process
=
_winapi
.
OpenProcess
(
_winapi
.
PROCESS_DUP_HANDLE
,
False
,
parent_pid
)
else
:
source_process
=
None
new_handle
=
reduction
.
duplicate
(
pipe_handle
,
source_process
=
source_process
)
fd
=
msvcrt
.
open_osfhandle
(
new_handle
,
os
.
O_RDONLY
)
fd
=
msvcrt
.
open_osfhandle
(
new_handle
,
os
.
O_RDONLY
)
else
:
else
:
from
.
import
semaphore_tracker
from
.
import
semaphore_tracker
...
...
Misc/NEWS.d/next/Library/2018-06-26-02-09-18.bpo-33929.OcCLah.rst
deleted
100644 → 0
Dosyayı görüntüle @
8b1ebcd7
multiprocessing: Fix a race condition in Popen of
multiprocessing.popen_spawn_win32. The child process now duplicates the read
end of pipe instead of "stealing" it. Previously, the read end of pipe was
"stolen" by the child process, but it leaked a handle if the child process had
been terminated before it could steal the handle from the parent process.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment