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
c0fdf6cf
Kaydet (Commit)
c0fdf6cf
authored
Mar 27, 2012
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Closes #14421: use with statement to properly close socket in bandwidth test.
üst
1641bb76
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
59 deletions
+59
-59
ccbench.py
Tools/ccbench/ccbench.py
+59
-59
No files found.
Tools/ccbench/ccbench.py
Dosyayı görüntüle @
c0fdf6cf
...
...
@@ -435,70 +435,70 @@ def run_bandwidth_client(**kwargs):
def
run_bandwidth_test
(
func
,
args
,
nthreads
):
# Create a listening socket to receive the packets. We use UDP which should
# be painlessly cross-platform.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
sock
.
bind
((
"127.0.0.1"
,
0
))
addr
=
sock
.
getsockname
()
with
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
as
sock
:
sock
.
bind
((
"127.0.0.1"
,
0
))
addr
=
sock
.
getsockname
()
duration
=
BANDWIDTH_DURATION
packet_size
=
BANDWIDTH_PACKET_SIZE
results
=
[]
threads
=
[]
end_event
=
[]
start_cond
=
threading
.
Condition
()
started
=
False
if
nthreads
>
0
:
# Warm up
func
(
*
args
)
duration
=
BANDWIDTH_DURATION
packet_size
=
BANDWIDTH_PACKET_SIZE
results
=
[]
loop
=
TimedLoop
(
func
,
args
)
ready
=
[]
ready_cond
=
threading
.
Condition
()
def
run
():
threads
=
[]
end_event
=
[]
start_cond
=
threading
.
Condition
()
started
=
False
if
nthreads
>
0
:
# Warm up
func
(
*
args
)
results
=
[]
loop
=
TimedLoop
(
func
,
args
)
ready
=
[]
ready_cond
=
threading
.
Condition
()
def
run
():
with
ready_cond
:
ready
.
append
(
None
)
ready_cond
.
notify
()
with
start_cond
:
while
not
started
:
start_cond
.
wait
()
loop
(
start_time
,
duration
*
1.5
,
end_event
,
do_yield
=
False
)
for
i
in
range
(
nthreads
):
threads
.
append
(
threading
.
Thread
(
target
=
run
))
for
t
in
threads
:
t
.
setDaemon
(
True
)
t
.
start
()
# Wait for threads to be ready
with
ready_cond
:
ready
.
append
(
None
)
ready_cond
.
notify
()
with
start_cond
:
while
not
started
:
start_cond
.
wait
()
loop
(
start_time
,
duration
*
1.5
,
end_event
,
do_yield
=
False
)
for
i
in
range
(
nthreads
):
threads
.
append
(
threading
.
Thread
(
target
=
run
))
for
t
in
threads
:
t
.
setDaemon
(
True
)
t
.
start
()
# Wait for threads to be ready
with
ready_cond
:
while
len
(
ready
)
<
nthreads
:
ready_cond
.
wait
()
# Run the client and wait for the first packet to arrive before
# unblocking the background threads.
process
=
run_bandwidth_client
(
addr
=
addr
,
packet_size
=
packet_size
,
duration
=
duration
)
_time
=
time
.
time
# This will also wait for the parent to be ready
s
=
_recv
(
sock
,
packet_size
)
remote_addr
=
eval
(
s
.
partition
(
'#'
)[
0
])
with
start_cond
:
start_time
=
_time
()
started
=
True
start_cond
.
notify
(
nthreads
)
n
=
0
first_time
=
None
while
not
end_event
and
BW_END
not
in
s
:
_sendto
(
sock
,
s
,
remote_addr
)
while
len
(
ready
)
<
nthreads
:
ready_cond
.
wait
()
# Run the client and wait for the first packet to arrive before
# unblocking the background threads.
process
=
run_bandwidth_client
(
addr
=
addr
,
packet_size
=
packet_size
,
duration
=
duration
)
_time
=
time
.
time
# This will also wait for the parent to be ready
s
=
_recv
(
sock
,
packet_size
)
if
first_time
is
None
:
first_time
=
_time
()
n
+=
1
end_time
=
_time
()
remote_addr
=
eval
(
s
.
partition
(
'#'
)[
0
])
with
start_cond
:
start_time
=
_time
()
started
=
True
start_cond
.
notify
(
nthreads
)
n
=
0
first_time
=
None
while
not
end_event
and
BW_END
not
in
s
:
_sendto
(
sock
,
s
,
remote_addr
)
s
=
_recv
(
sock
,
packet_size
)
if
first_time
is
None
:
first_time
=
_time
()
n
+=
1
end_time
=
_time
()
end_event
.
append
(
None
)
for
t
in
threads
:
...
...
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