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
2227251a
Kaydet (Commit)
2227251a
authored
Mar 17, 2010
tarafından
Collin Winter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix a race condition in test_asynchat uncovered by the Unladen Swallow JIT.
üst
0dee9c1b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
test_asynchat.py
Lib/test/test_asynchat.py
+13
-0
No files found.
Lib/test/test_asynchat.py
Dosyayı görüntüle @
2227251a
...
@@ -21,6 +21,9 @@ class echo_server(threading.Thread):
...
@@ -21,6 +21,9 @@ class echo_server(threading.Thread):
self
.
event
=
event
self
.
event
=
event
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
port
=
test_support
.
bind_port
(
self
.
sock
)
self
.
port
=
test_support
.
bind_port
(
self
.
sock
)
# This will be set if the client wants us to wait before echoing data
# back.
self
.
start_resend_event
=
None
def
run
(
self
):
def
run
(
self
):
self
.
sock
.
listen
(
1
)
self
.
sock
.
listen
(
1
)
...
@@ -37,6 +40,9 @@ class echo_server(threading.Thread):
...
@@ -37,6 +40,9 @@ class echo_server(threading.Thread):
# remove the SERVER_QUIT message
# remove the SERVER_QUIT message
self
.
buffer
=
self
.
buffer
.
replace
(
SERVER_QUIT
,
''
)
self
.
buffer
=
self
.
buffer
.
replace
(
SERVER_QUIT
,
''
)
if
self
.
start_resend_event
:
self
.
start_resend_event
.
wait
()
# re-send entire set of collected data
# re-send entire set of collected data
try
:
try
:
# this may fail on some tests, such as test_close_when_done, since
# this may fail on some tests, such as test_close_when_done, since
...
@@ -202,11 +208,18 @@ class TestAsynchat(unittest.TestCase):
...
@@ -202,11 +208,18 @@ class TestAsynchat(unittest.TestCase):
def
test_close_when_done
(
self
):
def
test_close_when_done
(
self
):
s
,
event
=
start_echo_server
()
s
,
event
=
start_echo_server
()
s
.
start_resend_event
=
threading
.
Event
()
c
=
echo_client
(
'
\n
'
,
s
.
port
)
c
=
echo_client
(
'
\n
'
,
s
.
port
)
c
.
push
(
"hello world
\n
I'm not dead yet!
\n
"
)
c
.
push
(
"hello world
\n
I'm not dead yet!
\n
"
)
c
.
push
(
SERVER_QUIT
)
c
.
push
(
SERVER_QUIT
)
c
.
close_when_done
()
c
.
close_when_done
()
asyncore
.
loop
(
use_poll
=
self
.
usepoll
,
count
=
300
,
timeout
=.
01
)
asyncore
.
loop
(
use_poll
=
self
.
usepoll
,
count
=
300
,
timeout
=.
01
)
# Only allow the server to start echoing data back to the client after
# the client has closed its connection. This prevents a race condition
# where the server echoes all of its data before we can check that it
# got any down below.
s
.
start_resend_event
.
set
()
s
.
join
()
s
.
join
()
self
.
assertEqual
(
c
.
contents
,
[])
self
.
assertEqual
(
c
.
contents
,
[])
...
...
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