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
04e60158
Commit
04e60158
authored
Jan 31, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweak test timeout for PyPy.
[skip appveyor]
parent
029a8d9f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
20 deletions
+21
-20
src/greentest/greentest/__init__.py
src/greentest/greentest/__init__.py
+1
-0
src/greentest/test__threadpool.py
src/greentest/test__threadpool.py
+20
-20
No files found.
src/greentest/greentest/__init__.py
View file @
04e60158
...
...
@@ -33,6 +33,7 @@ from greentest.sysinfo import LIBUV
from
greentest.sysinfo
import
CFFI_BACKEND
from
greentest.sysinfo
import
DEBUG
from
greentest.sysinfo
import
RUN_LEAKCHECKS
from
greentest.sysinfo
import
RUN_COVERAGE
from
greentest.sysinfo
import
PY2
from
greentest.sysinfo
import
PY3
...
...
src/greentest/test__threadpool.py
View file @
04e60158
...
...
@@ -74,12 +74,8 @@ class PoolBasicTests(TestCase):
def
raiser
():
raise
ExpectedException
()
try
:
with
self
.
assertRaises
(
ExpectedException
)
:
pool
.
apply
(
raiser
)
except
ExpectedException
:
pass
else
:
self
.
fail
(
"Should have raised ExpectedException"
)
# Don't let the metaclass automatically force any error
# that reaches the hub from a spawned greenlet to become
# fatal; that defeats the point of the test.
...
...
@@ -97,8 +93,8 @@ class PoolBasicTests(TestCase):
class
TimingWrapper
(
object
):
def
__init__
(
self
,
func
):
self
.
func
=
func
def
__init__
(
self
,
the_
func
):
self
.
func
=
the_
func
self
.
elapsed
=
None
def
__call__
(
self
,
*
args
,
**
kwds
):
...
...
@@ -147,10 +143,10 @@ class _AbstractPoolTest(TestCase):
SMALL_RANGE
=
10
LARGE_RANGE
=
1000
if
greentest
.
PYPY
and
greentest
.
WIN
:
# PyPy 5.
9 is *really* slow at spawning or switching between threads on Windows
#
Tests that happen instantaneously on other platforms
# time out due to the overhead
if
greentest
.
PYPY
and
(
greentest
.
WIN
or
greentest
.
RUN_COVERAGE
)
:
# PyPy 5.
10 is *really* slow at spawning or switching between
#
threads (especially on Windows or when coverage is enabled) Tests that happen
#
instantaneously on other platforms
time out due to the overhead
LARGE_RANGE
=
50
class
TestPool
(
_AbstractPoolTest
):
...
...
@@ -168,7 +164,7 @@ class TestPool(_AbstractPoolTest):
def
test_async_callback
(
self
):
result
=
[]
res
=
self
.
pool
.
apply_async
(
sqr
,
(
7
,
TIMEOUT1
,),
callback
=
lambda
x
:
result
.
append
(
x
)
)
res
=
self
.
pool
.
apply_async
(
sqr
,
(
7
,
TIMEOUT1
,),
callback
=
result
.
append
)
get
=
TimingWrapper
(
res
.
get
)
self
.
assertEqual
(
get
(),
49
)
self
.
assertTimeoutAlmostEqual
(
get
.
elapsed
,
TIMEOUT1
,
1
)
...
...
@@ -208,10 +204,11 @@ class TestPool(_AbstractPoolTest):
def
test_imap_unordered_gc
(
self
):
it
=
self
.
pool
.
imap_unordered
(
sqr
,
range
(
SMALL_RANGE
))
result
=
[]
for
i
in
range
(
SMALL_RANGE
):
for
_
in
range
(
SMALL_RANGE
):
result
.
append
(
six
.
advance_iterator
(
it
))
gc
.
collect
()
self
.
assertRaises
(
StopIteration
,
lambda
:
six
.
advance_iterator
(
it
))
with
self
.
assertRaises
(
StopIteration
):
six
.
advance_iterator
(
it
)
self
.
assertEqual
(
sorted
(
result
),
[
x
*
x
for
x
in
range
(
SMALL_RANGE
)])
def
test_imap_random
(
self
):
...
...
@@ -439,9 +436,10 @@ class TestRef(TestCase):
if
PYPY
:
gc
.
collect
()
gc
.
collect
()
for
index
,
r
in
enumerate
(
refs
):
assert
r
()
is
None
,
(
index
,
r
(),
greentest
.
getrefcount
(
r
()),
refs
)
assert
len
(
refs
)
==
4
,
refs
for
r
in
refs
:
self
.
assertIsNone
(
r
())
self
.
assertEqual
(
4
,
len
(
refs
))
class
Object
(
object
):
...
...
@@ -450,13 +448,15 @@ class Object(object):
class
SomeClass
(
object
):
refs
=
None
def
func
(
self
,
arg1
,
kwarg1
=
None
):
result
=
Object
()
self
.
refs
.
extend
([
weakref
.
ref
(
x
)
for
x
in
[
arg1
,
kwarg1
,
result
]])
return
result
def
func
():
def
noop
():
pass
...
...
@@ -464,7 +464,7 @@ class TestRefCount(TestCase):
def
test
(
self
):
pool
=
ThreadPool
(
1
)
pool
.
spawn
(
func
)
pool
.
spawn
(
noop
)
gevent
.
sleep
(
0
)
pool
.
kill
()
...
...
@@ -499,7 +499,7 @@ if hasattr(gevent.threadpool, 'ThreadPoolExecutor'):
def
callback
(
future
):
future
.
calledback
+=
1
raise
Exception
(
"Expected, ignored"
)
raise
greentest
.
Expected
Exception
(
"Expected, ignored"
)
future
=
pool
.
submit
(
fn
)
future
.
calledback
=
0
...
...
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