Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
e075751c
Commit
e075751c
authored
Dec 09, 2020
by
Jason Madden
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue1711'
parents
19cf5f4a
2d8a5636
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
src/gevent/testing/testcase.py
src/gevent/testing/testcase.py
+4
-4
src/gevent/tests/test__threadpool.py
src/gevent/tests/test__threadpool.py
+7
-6
No files found.
src/gevent/testing/testcase.py
View file @
e075751c
...
...
@@ -58,14 +58,14 @@ class TimeAssertMixin(object):
self
.
assertGreaterEqual
(
time_taken
,
min_time
)
@
contextmanager
def
runs_in_given_time
(
self
,
expected
,
fuzzy
=
None
):
def
runs_in_given_time
(
self
,
expected
,
fuzzy
=
None
,
min_time
=
None
):
if
fuzzy
is
None
:
if
sysinfo
.
EXPECT_POOR_TIMER_RESOLUTION
or
sysinfo
.
LIBUV
:
# The noted timer jitter issues on appveyor/pypy3
fuzzy
=
expected
*
5.0
else
:
fuzzy
=
expected
/
2.0
min_time
=
expected
-
fuzzy
min_time
=
min_time
if
min_time
is
not
None
else
expected
-
fuzzy
max_time
=
expected
+
fuzzy
start
=
perf_counter
()
yield
(
min_time
,
max_time
)
...
...
@@ -73,8 +73,8 @@ class TimeAssertMixin(object):
try
:
self
.
assertTrue
(
min_time
<=
elapsed
<=
max_time
,
'Expected: %r; elapsed: %r; fuzzy %r; clock_info: %s'
%
(
expected
,
elapsed
,
fuzzy
,
get_clock_info
(
'perf_counter'
)
'Expected: %r; elapsed: %r;
min: %r; max: %r;
fuzzy %r; clock_info: %s'
%
(
expected
,
elapsed
,
min_time
,
max_time
,
fuzzy
,
get_clock_info
(
'perf_counter'
)
))
except
AssertionError
:
flaky
.
reraiseFlakyTestRaceCondition
()
...
...
src/gevent/tests/test__threadpool.py
View file @
e075751c
...
...
@@ -212,7 +212,7 @@ class TestPool(_AbstractPoolTest):
self
.
assertEqual
(
get
(),
49
)
self
.
assertTimeoutAlmostEqual
(
get
.
elapsed
,
TIMEOUT1
,
1
)
gevent
.
sleep
(
0
)
# lets the callback run
assert
result
==
[
49
],
result
self
.
assertEqual
(
result
,
[
49
])
def
test_async_timeout
(
self
):
res
=
self
.
pool
.
apply_async
(
sqr
,
(
6
,
TIMEOUT2
+
0.2
))
...
...
@@ -273,10 +273,11 @@ class TestPool(_AbstractPoolTest):
size
=
self
.
size
or
10
result
=
self
.
pool
.
map_async
(
sleep
,
[
0.1
]
*
(
size
*
2
))
gevent
.
sleep
(
0.1
)
kill
=
TimingWrapper
(
self
.
pool
.
kill
)
kill
()
assert
kill
.
elapsed
<
0.1
*
self
.
size
+
0.5
,
kill
.
elapsed
result
.
join
()
try
:
with
self
.
runs_in_given_time
(
0.1
*
self
.
size
+
0.5
,
min_time
=
0
):
self
.
pool
.
kill
()
finally
:
result
.
join
()
def
sleep
(
self
,
x
):
sleep
(
float
(
x
)
/
10.0
)
...
...
@@ -485,7 +486,7 @@ class TestRef(TestCase):
# result = func(Object(), kwarg1=Object())
# but in a thread pool and see that arguments', result's and func's references are not leaked
result
=
pool
.
apply
(
func
,
(
Object
(),
),
{
'kwarg1'
:
Object
()})
assert
isinstance
(
result
,
Object
),
repr
(
resul
t
)
self
.
assertIsInstance
(
result
,
Objec
t
)
gevent
.
sleep
(
0.1
)
# XXX should not be needed
refs
.
append
(
weakref
.
ref
(
func
))
...
...
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