Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a23dd513
Commit
a23dd513
authored
Oct 20, 2013
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #19305: try to fix sporadic test_asyncio failure on FreeBSD 10.0
parent
0d172202
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
Lib/asyncio/test_utils.py
Lib/asyncio/test_utils.py
+15
-0
Lib/test/test_asyncio/test_events.py
Lib/test/test_asyncio/test_events.py
+5
-2
No files found.
Lib/asyncio/test_utils.py
View file @
a23dd513
...
...
@@ -7,6 +7,7 @@ import unittest.mock
import
os
import
sys
import
threading
import
time
import
unittest
import
unittest.mock
from
wsgiref.simple_server
import
make_server
,
WSGIRequestHandler
,
WSGIServer
...
...
@@ -46,6 +47,20 @@ def run_briefly(loop):
gen
.
close
()
def
run_until
(
loop
,
pred
,
timeout
=
None
):
if
timeout
is
not
None
:
deadline
=
time
.
time
()
+
timeout
while
not
pred
():
if
timeout
is
not
None
:
timeout
=
deadline
-
time
.
time
()
if
timeout
<=
0
:
return
False
loop
.
run_until_complete
(
tasks
.
sleep
(
timeout
,
loop
=
loop
))
else
:
run_briefly
(
loop
)
return
True
def
run_once
(
loop
):
"""loop.stop() schedules _raise_stop_error()
and run_forever() runs until _raise_stop_error() callback.
...
...
Lib/test/test_asyncio/test_events.py
View file @
a23dd513
...
...
@@ -558,13 +558,14 @@ class EventLoopTestsMixin:
self
.
assertEqual
(
host
,
'0.0.0.0'
)
client
=
socket
.
socket
()
client
.
connect
((
'127.0.0.1'
,
port
))
client
.
send
(
b'xxx'
)
client
.
send
all
(
b'xxx'
)
test_utils
.
run_briefly
(
self
.
loop
)
self
.
assertIsInstance
(
proto
,
MyProto
)
self
.
assertEqual
(
'INITIAL'
,
proto
.
state
)
test_utils
.
run_briefly
(
self
.
loop
)
self
.
assertEqual
(
'CONNECTED'
,
proto
.
state
)
test_utils
.
run_briefly
(
self
.
loop
)
# windows iocp
test_utils
.
run_until
(
self
.
loop
,
lambda
:
proto
.
nbytes
>
0
,
timeout
=
10
)
self
.
assertEqual
(
3
,
proto
.
nbytes
)
# extra info is available
...
...
@@ -623,6 +624,8 @@ class EventLoopTestsMixin:
self
.
assertIsInstance
(
proto
,
MyProto
)
test_utils
.
run_briefly
(
self
.
loop
)
self
.
assertEqual
(
'CONNECTED'
,
proto
.
state
)
test_utils
.
run_until
(
self
.
loop
,
lambda
:
proto
.
nbytes
>
0
,
timeout
=
10
)
self
.
assertEqual
(
3
,
proto
.
nbytes
)
# extra info is available
...
...
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