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
3cb09064
Kaydet (Commit)
3cb09064
authored
May 16, 2013
tarafından
Giampaolo Rodola'
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #17992: Add timeouts to asyncore and asynchat tests so that they won't accidentally hang.
üst
0d4f08ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
10 deletions
+35
-10
test_asynchat.py
Lib/test/test_asynchat.py
+22
-7
test_asyncore.py
Lib/test/test_asyncore.py
+10
-3
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_asynchat.py
Dosyayı görüntüle @
3cb09064
...
@@ -15,6 +15,7 @@ except ImportError:
...
@@ -15,6 +15,7 @@ except ImportError:
HOST
=
support
.
HOST
HOST
=
support
.
HOST
SERVER_QUIT
=
b
'QUIT
\n
'
SERVER_QUIT
=
b
'QUIT
\n
'
TIMEOUT
=
3.0
if
threading
:
if
threading
:
class
echo_server
(
threading
.
Thread
):
class
echo_server
(
threading
.
Thread
):
...
@@ -123,7 +124,9 @@ class TestAsynchat(unittest.TestCase):
...
@@ -123,7 +124,9 @@ class TestAsynchat(unittest.TestCase):
c
.
push
(
b
"I'm not dead yet!"
+
term
)
c
.
push
(
b
"I'm not dead yet!"
+
term
)
c
.
push
(
SERVER_QUIT
)
c
.
push
(
SERVER_QUIT
)
asyncore
.
loop
(
use_poll
=
self
.
usepoll
,
count
=
300
,
timeout
=.
01
)
asyncore
.
loop
(
use_poll
=
self
.
usepoll
,
count
=
300
,
timeout
=.
01
)
s
.
join
()
s
.
join
(
timeout
=
TIMEOUT
)
if
s
.
is_alive
():
self
.
fail
(
"join() timed out"
)
self
.
assertEqual
(
c
.
contents
,
[
b
"hello world"
,
b
"I'm not dead yet!"
])
self
.
assertEqual
(
c
.
contents
,
[
b
"hello world"
,
b
"I'm not dead yet!"
])
...
@@ -154,7 +157,9 @@ class TestAsynchat(unittest.TestCase):
...
@@ -154,7 +157,9 @@ class TestAsynchat(unittest.TestCase):
c
.
push
(
data
)
c
.
push
(
data
)
c
.
push
(
SERVER_QUIT
)
c
.
push
(
SERVER_QUIT
)
asyncore
.
loop
(
use_poll
=
self
.
usepoll
,
count
=
300
,
timeout
=.
01
)
asyncore
.
loop
(
use_poll
=
self
.
usepoll
,
count
=
300
,
timeout
=.
01
)
s
.
join
()
s
.
join
(
timeout
=
TIMEOUT
)
if
s
.
is_alive
():
self
.
fail
(
"join() timed out"
)
self
.
assertEqual
(
c
.
contents
,
[
data
[:
termlen
]])
self
.
assertEqual
(
c
.
contents
,
[
data
[:
termlen
]])
...
@@ -174,7 +179,9 @@ class TestAsynchat(unittest.TestCase):
...
@@ -174,7 +179,9 @@ class TestAsynchat(unittest.TestCase):
c
.
push
(
data
)
c
.
push
(
data
)
c
.
push
(
SERVER_QUIT
)
c
.
push
(
SERVER_QUIT
)
asyncore
.
loop
(
use_poll
=
self
.
usepoll
,
count
=
300
,
timeout
=.
01
)
asyncore
.
loop
(
use_poll
=
self
.
usepoll
,
count
=
300
,
timeout
=.
01
)
s
.
join
()
s
.
join
(
timeout
=
TIMEOUT
)
if
s
.
is_alive
():
self
.
fail
(
"join() timed out"
)
self
.
assertEqual
(
c
.
contents
,
[])
self
.
assertEqual
(
c
.
contents
,
[])
self
.
assertEqual
(
c
.
buffer
,
data
)
self
.
assertEqual
(
c
.
buffer
,
data
)
...
@@ -186,7 +193,9 @@ class TestAsynchat(unittest.TestCase):
...
@@ -186,7 +193,9 @@ class TestAsynchat(unittest.TestCase):
p
=
asynchat
.
simple_producer
(
data
+
SERVER_QUIT
,
buffer_size
=
8
)
p
=
asynchat
.
simple_producer
(
data
+
SERVER_QUIT
,
buffer_size
=
8
)
c
.
push_with_producer
(
p
)
c
.
push_with_producer
(
p
)
asyncore
.
loop
(
use_poll
=
self
.
usepoll
,
count
=
300
,
timeout
=.
01
)
asyncore
.
loop
(
use_poll
=
self
.
usepoll
,
count
=
300
,
timeout
=.
01
)
s
.
join
()
s
.
join
(
timeout
=
TIMEOUT
)
if
s
.
is_alive
():
self
.
fail
(
"join() timed out"
)
self
.
assertEqual
(
c
.
contents
,
[
b
"hello world"
,
b
"I'm not dead yet!"
])
self
.
assertEqual
(
c
.
contents
,
[
b
"hello world"
,
b
"I'm not dead yet!"
])
...
@@ -196,7 +205,9 @@ class TestAsynchat(unittest.TestCase):
...
@@ -196,7 +205,9 @@ class TestAsynchat(unittest.TestCase):
data
=
b
"hello world
\n
I'm not dead yet!
\n
"
data
=
b
"hello world
\n
I'm not dead yet!
\n
"
c
.
push_with_producer
(
data
+
SERVER_QUIT
)
c
.
push_with_producer
(
data
+
SERVER_QUIT
)
asyncore
.
loop
(
use_poll
=
self
.
usepoll
,
count
=
300
,
timeout
=.
01
)
asyncore
.
loop
(
use_poll
=
self
.
usepoll
,
count
=
300
,
timeout
=.
01
)
s
.
join
()
s
.
join
(
timeout
=
TIMEOUT
)
if
s
.
is_alive
():
self
.
fail
(
"join() timed out"
)
self
.
assertEqual
(
c
.
contents
,
[
b
"hello world"
,
b
"I'm not dead yet!"
])
self
.
assertEqual
(
c
.
contents
,
[
b
"hello world"
,
b
"I'm not dead yet!"
])
...
@@ -207,7 +218,9 @@ class TestAsynchat(unittest.TestCase):
...
@@ -207,7 +218,9 @@ class TestAsynchat(unittest.TestCase):
c
.
push
(
b
"hello world
\n\n
I'm not dead yet!
\n
"
)
c
.
push
(
b
"hello world
\n\n
I'm not dead yet!
\n
"
)
c
.
push
(
SERVER_QUIT
)
c
.
push
(
SERVER_QUIT
)
asyncore
.
loop
(
use_poll
=
self
.
usepoll
,
count
=
300
,
timeout
=.
01
)
asyncore
.
loop
(
use_poll
=
self
.
usepoll
,
count
=
300
,
timeout
=.
01
)
s
.
join
()
s
.
join
(
timeout
=
TIMEOUT
)
if
s
.
is_alive
():
self
.
fail
(
"join() timed out"
)
self
.
assertEqual
(
c
.
contents
,
self
.
assertEqual
(
c
.
contents
,
[
b
"hello world"
,
b
""
,
b
"I'm not dead yet!"
])
[
b
"hello world"
,
b
""
,
b
"I'm not dead yet!"
])
...
@@ -226,7 +239,9 @@ class TestAsynchat(unittest.TestCase):
...
@@ -226,7 +239,9 @@ class TestAsynchat(unittest.TestCase):
# where the server echoes all of its data before we can check that it
# where the server echoes all of its data before we can check that it
# got any down below.
# got any down below.
s
.
start_resend_event
.
set
()
s
.
start_resend_event
.
set
()
s
.
join
()
s
.
join
(
timeout
=
TIMEOUT
)
if
s
.
is_alive
():
self
.
fail
(
"join() timed out"
)
self
.
assertEqual
(
c
.
contents
,
[])
self
.
assertEqual
(
c
.
contents
,
[])
# the server might have been able to send a byte or two back, but this
# the server might have been able to send a byte or two back, but this
...
...
Lib/test/test_asyncore.py
Dosyayı görüntüle @
3cb09064
...
@@ -20,7 +20,7 @@ except ImportError:
...
@@ -20,7 +20,7 @@ except ImportError:
threading
=
None
threading
=
None
HOST
=
support
.
HOST
HOST
=
support
.
HOST
TIMEOUT
=
3
HAS_UNIX_SOCKETS
=
hasattr
(
socket
,
'AF_UNIX'
)
HAS_UNIX_SOCKETS
=
hasattr
(
socket
,
'AF_UNIX'
)
class
dummysocket
:
class
dummysocket
:
...
@@ -397,7 +397,10 @@ class DispatcherWithSendTests(unittest.TestCase):
...
@@ -397,7 +397,10 @@ class DispatcherWithSendTests(unittest.TestCase):
self
.
assertEqual
(
cap
.
getvalue
(),
data
*
2
)
self
.
assertEqual
(
cap
.
getvalue
(),
data
*
2
)
finally
:
finally
:
t
.
join
()
t
.
join
(
timeout
=
TIMEOUT
)
if
t
.
is_alive
():
self
.
fail
(
"join() timed out"
)
class
DispatcherWithSendTests_UsePoll
(
DispatcherWithSendTests
):
class
DispatcherWithSendTests_UsePoll
(
DispatcherWithSendTests
):
...
@@ -789,7 +792,11 @@ class BaseTestAPI:
...
@@ -789,7 +792,11 @@ class BaseTestAPI:
t
=
threading
.
Thread
(
target
=
lambda
:
asyncore
.
loop
(
timeout
=
0.1
,
t
=
threading
.
Thread
(
target
=
lambda
:
asyncore
.
loop
(
timeout
=
0.1
,
count
=
500
))
count
=
500
))
t
.
start
()
t
.
start
()
self
.
addCleanup
(
t
.
join
)
def
cleanup
():
t
.
join
(
timeout
=
TIMEOUT
)
if
t
.
is_alive
():
self
.
fail
(
"join() timed out"
)
self
.
addCleanup
(
cleanup
)
s
=
socket
.
socket
(
self
.
family
,
socket
.
SOCK_STREAM
)
s
=
socket
.
socket
(
self
.
family
,
socket
.
SOCK_STREAM
)
s
.
settimeout
(
.
2
)
s
.
settimeout
(
.
2
)
...
...
Misc/NEWS
Dosyayı görüntüle @
3cb09064
...
@@ -258,6 +258,9 @@ Library
...
@@ -258,6 +258,9 @@ Library
Tests
Tests
-----
-----
-
Issue
#
17992
:
Add
timeouts
to
asyncore
and
asynchat
tests
so
that
they
won
't
accidentally hang.
- Issue #17833: Fix test_gdb failures seen on machines where debug symbols
- Issue #17833: Fix test_gdb failures seen on machines where debug symbols
for glibc are available (seen on PPC64 Linux).
for glibc are available (seen on PPC64 Linux).
...
...
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