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
03989859
Kaydet (Commit)
03989859
authored
Agu 27, 2012
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #15781: Fix two small race conditions in import's module locking.
üst
30147710
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
4 deletions
+26
-4
_bootstrap.py
Lib/importlib/_bootstrap.py
+8
-2
test_threaded_import.py
Lib/test/test_threaded_import.py
+11
-1
NEWS
Misc/NEWS
+2
-0
import.c
Python/import.c
+5
-1
importlib.h
Python/importlib.h
+0
-0
No files found.
Lib/importlib/_bootstrap.py
Dosyayı görüntüle @
03989859
...
...
@@ -268,8 +268,10 @@ def _get_module_lock(name):
Should only be called with the import lock taken."""
lock
=
None
if
name
in
_module_locks
:
try
:
lock
=
_module_locks
[
name
]()
except
KeyError
:
pass
if
lock
is
None
:
if
_thread
is
None
:
lock
=
_DummyModuleLock
(
name
)
...
...
@@ -543,6 +545,9 @@ def module_for_loader(fxn):
# implicitly imports 'locale' and would otherwise trigger an
# infinite loop.
module
=
new_module
(
fullname
)
# This must be done before putting the module in sys.modules
# (otherwise an optimization shortcut in import.c becomes wrong)
module
.
__initializing__
=
True
sys
.
modules
[
fullname
]
=
module
module
.
__loader__
=
self
try
:
...
...
@@ -554,8 +559,9 @@ def module_for_loader(fxn):
module
.
__package__
=
fullname
else
:
module
.
__package__
=
fullname
.
rpartition
(
'.'
)[
0
]
try
:
else
:
module
.
__initializing__
=
True
try
:
# If __package__ was not set above, __import__() will do it later.
return
fxn
(
self
,
module
,
*
args
,
**
kwargs
)
except
:
...
...
Lib/test/test_threaded_import.py
Dosyayı görüntüle @
03989859
...
...
@@ -224,7 +224,17 @@ class ThreadedImportTests(unittest.TestCase):
@reap_threads
def
test_main
():
run_unittest
(
ThreadedImportTests
)
old_switchinterval
=
None
try
:
old_switchinterval
=
sys
.
getswitchinterval
()
sys
.
setswitchinterval
(
0.00000001
)
except
AttributeError
:
pass
try
:
run_unittest
(
ThreadedImportTests
)
finally
:
if
old_switchinterval
is
not
None
:
sys
.
setswitchinterval
(
old_switchinterval
)
if
__name__
==
"__main__"
:
test_main
()
Misc/NEWS
Dosyayı görüntüle @
03989859
...
...
@@ -13,6 +13,8 @@ Core and Builtins
- Issue #15784: Modify OSError.__str__() to better distinguish between
errno error numbers and Windows error numbers.
- Issue #15781: Fix two small race conditions in import'
s
module
locking
.
Library
-------
...
...
Python/import.c
Dosyayı görüntüle @
03989859
...
...
@@ -1408,7 +1408,11 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals,
int
initializing
=
0
;
Py_INCREF
(
mod
);
/* Only call _bootstrap._lock_unlock_module() if __initializing__ is true. */
/* Optimization: only call _bootstrap._lock_unlock_module() if
__initializing__ is true.
NOTE: because of this, __initializing__ must be set *before*
stuffing the new module in sys.modules.
*/
value
=
_PyObject_GetAttrId
(
mod
,
&
PyId___initializing__
);
if
(
value
==
NULL
)
PyErr_Clear
();
...
...
Python/importlib.h
Dosyayı görüntüle @
03989859
This diff is collapsed.
Click to expand it.
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