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
91012fe9
Kaydet (Commit)
91012fe9
authored
Haz 13, 2003
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Cause calling interrupt_main in main thread raise KeyboardInterrupt instantly.
üst
4e64d78b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
dummy_thread.py
Lib/dummy_thread.py
+12
-4
test_dummy_thread.py
Lib/test/test_dummy_thread.py
+5
-0
No files found.
Lib/dummy_thread.py
Dosyayı görüntüle @
91012fe9
...
...
@@ -44,14 +44,17 @@ def start_new_thread(function, args, kwargs={}):
raise
TypeError
(
"2nd arg must be a tuple"
)
if
type
(
kwargs
)
!=
type
(
dict
()):
raise
TypeError
(
"3rd arg must be a dict"
)
global
_main
_main
=
False
try
:
function
(
*
args
,
**
kwargs
)
except
SystemExit
:
pass
except
:
_traceback
.
print_exc
()
_main
=
True
global
_interrupt
if
_interrupt
:
global
_interrupt
_interrupt
=
False
raise
KeyboardInterrupt
...
...
@@ -122,11 +125,16 @@ class LockType(object):
def
locked
(
self
):
return
self
.
locked_status
# Used to signal that interrupt_main was called in a "thread"
_interrupt
=
False
# True when not executing in a "thread"
_main
=
True
def
interrupt_main
():
"""Set _interrupt flag to True to have start_new_thread raise
KeyboardInterrupt upon exiting."""
global
_interrupt
_interrupt
=
True
if
_main
:
raise
KeyboardInterrupt
else
:
global
_interrupt
_interrupt
=
True
Lib/test/test_dummy_thread.py
Dosyayı görüntüle @
91012fe9
...
...
@@ -109,6 +109,11 @@ class MiscTests(unittest.TestCase):
_thread
.
interrupt_main
()
self
.
failUnlessRaises
(
KeyboardInterrupt
,
_thread
.
start_new_thread
,
call_interrupt
,
tuple
())
def
test_interrupt_in_main
(
self
):
# Make sure that if interrupt_main is called in main threat that
# KeyboardInterrupt is raised instantly.
self
.
failUnlessRaises
(
KeyboardInterrupt
,
_thread
.
interrupt_main
)
class
ThreadTests
(
unittest
.
TestCase
):
"""Test thread creation."""
...
...
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