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
2a4712dc
Kaydet (Commit)
2a4712dc
authored
Ock 24, 2006
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
test_rude_shutdown(): Rewrote to use proper thread
synchronization and termination.
üst
92037a15
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
11 deletions
+19
-11
test_socket_ssl.py
Lib/test/test_socket_ssl.py
+19
-11
No files found.
Lib/test/test_socket_ssl.py
Dosyayı görüntüle @
2a4712dc
...
...
@@ -2,7 +2,6 @@
from
test
import
test_support
import
socket
import
time
# Optionally test SSL support. This requires the 'network' resource as given
# on the regrtest command line.
...
...
@@ -29,34 +28,43 @@ def test_basic():
def
test_rude_shutdown
():
try
:
import
thread
import
thread
ing
except
ImportError
:
return
#
some random port to connect to
#
Some random port to connect to.
PORT
=
9934
listener_gone
=
threading
.
Event
()
# `listener` runs in a thread. It opens a socket listening on PORT, and
# sits in an accept() until the main thread connects. Then it rudely
# closes the socket, and sets Event `listener_gone` to let the main thread
# know the socket is gone.
def
listener
():
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
=
socket
.
socket
()
s
.
bind
((
''
,
PORT
))
s
.
listen
(
5
)
s
.
accept
()
del
s
thread
.
exi
t
()
s
=
None
# reclaim the socket object, which also closes it
listener_gone
.
se
t
()
def
connector
():
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
=
socket
.
socket
()
s
.
connect
((
'localhost'
,
PORT
))
listener_gone
.
wait
()
try
:
ssl_sock
=
socket
.
ssl
(
s
)
except
socket
.
sslerror
:
pass
else
:
raise
test_support
.
TestFailed
,
\
'connecting to closed SSL socket failed'
raise
test_support
.
TestFailed
(
'connecting to closed SSL socket should have failed'
)
t
hread
.
start_new_thread
(
listener
,
()
)
t
ime
.
sleep
(
1
)
t
=
threading
.
Thread
(
target
=
listener
)
t
.
start
(
)
connector
()
t
.
join
()
def
test_main
():
if
not
hasattr
(
socket
,
"ssl"
):
...
...
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