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
8f078aa9
Commit
8f078aa9
authored
Apr 30, 2012
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test__threadpool.py: add TestRef
parent
2c006a7c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
greentest/test__threadpool.py
greentest/test__threadpool.py
+40
-0
No files found.
greentest/test__threadpool.py
View file @
8f078aa9
import
sys
from
time
import
time
,
sleep
import
random
import
weakref
import
greentest
from
gevent.threadpool
import
ThreadPool
import
gevent
...
...
@@ -296,5 +298,43 @@ class TestSize(TestCase):
self
.
assertEqual
(
pool
.
size
,
2
)
class
TestRef
(
TestCase
):
def
test
(
self
):
pool
=
self
.
pool
=
ThreadPool
(
2
)
refs
=
[]
obj
=
SomeClass
()
obj
.
refs
=
refs
func
=
obj
.
func
del
obj
with
greentest
.
disabled_gc
():
# we do this:
# 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
(
result
)
gevent
.
sleep
(
0
)
# XXX should not be needed
refs
.
append
(
weakref
.
ref
(
func
))
del
func
,
result
for
index
,
r
in
enumerate
(
refs
):
assert
r
()
is
None
,
(
index
,
r
(),
sys
.
getrefcount
(
r
()),
refs
)
assert
len
(
refs
)
==
4
,
refs
class
Object
(
object
):
pass
class
SomeClass
(
object
):
def
func
(
self
,
arg1
,
kwarg1
=
None
):
result
=
Object
()
self
.
refs
.
extend
([
weakref
.
ref
(
x
)
for
x
in
[
arg1
,
kwarg1
,
result
]])
return
result
if
__name__
==
'__main__'
:
greentest
.
main
()
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