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
d874c055
Kaydet (Commit)
d874c055
authored
Agu 20, 2016
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #27614: Avoid race in test_docxmlrpc server setup
üst
68c1f1ed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
30 deletions
+11
-30
test_docxmlrpc.py
Lib/test/test_docxmlrpc.py
+11
-30
No files found.
Lib/test/test_docxmlrpc.py
Dosyayı görüntüle @
d874c055
...
...
@@ -3,12 +3,8 @@ import http.client
import
sys
from
test
import
support
threading
=
support
.
import_module
(
'threading'
)
import
time
import
socket
import
unittest
PORT
=
None
def
make_request_and_skipIf
(
condition
,
reason
):
# If we skip the test, we have to make a request because
# the server created in setUp blocks expecting one to come in.
...
...
@@ -23,13 +19,10 @@ def make_request_and_skipIf(condition, reason):
return
decorator
def
server
(
evt
,
numrequests
):
def
make_server
(
):
serv
=
DocXMLRPCServer
((
"localhost"
,
0
),
logRequests
=
False
)
try
:
global
PORT
PORT
=
serv
.
socket
.
getsockname
()[
1
]
# Add some documentation
serv
.
set_server_title
(
"DocXMLRPCServer Test Documentation"
)
serv
.
set_server_name
(
"DocXMLRPCServer Test Docs"
)
...
...
@@ -66,43 +59,31 @@ def server(evt, numrequests):
serv
.
register_function
(
lambda
x
,
y
:
x
-
y
)
serv
.
register_function
(
annotation
)
serv
.
register_instance
(
ClassWithAnnotation
())
while
numrequests
>
0
:
serv
.
handle_request
()
numrequests
-=
1
except
socket
.
timeout
:
pass
finally
:
return
serv
except
:
serv
.
server_close
()
PORT
=
None
evt
.
set
()
raise
class
DocXMLRPCHTTPGETServer
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
_threads
=
support
.
threading_setup
()
# Enable server feedback
DocXMLRPCServer
.
_send_traceback_header
=
True
self
.
evt
=
threading
.
Event
()
threading
.
Thread
(
target
=
server
,
args
=
(
self
.
evt
,
1
))
.
start
()
# wait for port to be assigned
deadline
=
time
.
monotonic
()
+
10.0
while
PORT
is
None
:
time
.
sleep
(
0.010
)
if
time
.
monotonic
()
>
deadline
:
break
self
.
serv
=
make_server
()
self
.
thread
=
threading
.
Thread
(
target
=
self
.
serv
.
serve_forever
)
self
.
thread
.
start
()
PORT
=
self
.
serv
.
server_address
[
1
]
self
.
client
=
http
.
client
.
HTTPConnection
(
"localhost:
%
d"
%
PORT
)
def
tearDown
(
self
):
self
.
client
.
close
()
self
.
evt
.
wait
()
# Disable server feedback
DocXMLRPCServer
.
_send_traceback_header
=
False
support
.
threading_cleanup
(
*
self
.
_threads
)
self
.
serv
.
shutdown
()
self
.
thread
.
join
()
self
.
serv
.
server_close
()
def
test_valid_get_response
(
self
):
self
.
client
.
request
(
"GET"
,
"/"
)
...
...
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