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
21432b20
Commit
21432b20
authored
Aug 01, 2011
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update test__queue.py
parent
3c77208b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
14 deletions
+34
-14
greentest/test__queue.py
greentest/test__queue.py
+34
-14
No files found.
greentest/test__queue.py
View file @
21432b20
...
...
@@ -3,6 +3,7 @@ import gevent
from
gevent.hub
import
get_hub
from
gevent
import
util
from
gevent
import
queue
from
gevent.queue
import
Empty
,
Full
from
gevent.event
import
AsyncResult
...
...
@@ -55,7 +56,7 @@ class TestQueue(TestCase):
assert
p
.
get
(
timeout
=
0
)
==
"OK"
def
test_zero_max_size
(
self
):
q
=
queue
.
Queue
(
0
)
q
=
queue
.
Channel
(
)
def
sender
(
evt
,
q
):
q
.
put
(
'hi'
)
...
...
@@ -192,7 +193,7 @@ class TestQueue(TestCase):
class
TestChannel
(
TestCase
):
def
test_send
(
self
):
channel
=
queue
.
Queue
(
0
)
channel
=
queue
.
Channel
(
)
events
=
[]
...
...
@@ -212,7 +213,7 @@ class TestChannel(TestCase):
g
.
get
()
def
test_wait
(
self
):
channel
=
queue
.
Queue
(
0
)
channel
=
queue
.
Channel
(
)
events
=
[]
def
another_greenlet
():
...
...
@@ -255,8 +256,8 @@ class TestNoWait(TestCase):
run_callback
=
get_hub
().
loop
.
run_callback
run_callback
(
store_result
,
util
.
wrap_errors
(
Exception
,
q
.
put_nowait
),
2
)
run_callback
(
store_result
,
util
.
wrap_errors
(
Exception
,
q
.
put_nowait
),
3
)
run_callback
(
store_result
,
util
.
wrap_errors
(
Full
,
q
.
put_nowait
),
2
)
run_callback
(
store_result
,
util
.
wrap_errors
(
Full
,
q
.
put_nowait
),
3
)
gevent
.
sleep
(
0
)
assert
len
(
result
)
==
2
,
result
assert
result
[
0
]
==
None
,
result
...
...
@@ -272,8 +273,8 @@ class TestNoWait(TestCase):
run_callback
=
get_hub
().
loop
.
run_callback
run_callback
(
store_result
,
util
.
wrap_errors
(
E
xception
,
q
.
get_nowait
))
run_callback
(
store_result
,
util
.
wrap_errors
(
E
xception
,
q
.
get_nowait
))
run_callback
(
store_result
,
util
.
wrap_errors
(
E
mpty
,
q
.
get_nowait
))
run_callback
(
store_result
,
util
.
wrap_errors
(
E
mpty
,
q
.
get_nowait
))
gevent
.
sleep
(
0
)
assert
len
(
result
)
==
2
,
result
assert
result
[
0
]
==
4
,
result
...
...
@@ -282,7 +283,26 @@ class TestNoWait(TestCase):
# get_nowait must work from the mainloop
def
test_get_nowait_unlock
(
self
):
result
=
[]
q
=
queue
.
Queue
(
0
)
q
=
queue
.
Queue
(
1
)
p
=
gevent
.
spawn
(
q
.
put
,
5
)
def
store_result
(
func
,
*
args
):
result
.
append
(
func
(
*
args
))
assert
q
.
empty
(),
q
gevent
.
sleep
(
0
)
assert
q
.
full
(),
q
get_hub
().
loop
.
run_callback
(
store_result
,
q
.
get_nowait
)
gevent
.
sleep
(
0
)
assert
q
.
empty
(),
q
assert
result
==
[
5
],
result
assert
p
.
ready
(),
p
assert
p
.
dead
,
p
assert
q
.
empty
(),
q
def
test_get_nowait_unlock_channel
(
self
):
result
=
[]
q
=
queue
.
Channel
()
p
=
gevent
.
spawn
(
q
.
put
,
5
)
def
store_result
(
func
,
*
args
):
...
...
@@ -293,7 +313,7 @@ class TestNoWait(TestCase):
gevent
.
sleep
(
0
)
assert
q
.
empty
(),
q
assert
q
.
full
(),
q
get_hub
().
loop
.
run_callback
(
store_result
,
util
.
wrap_errors
(
Exception
,
q
.
get_nowait
)
)
get_hub
().
loop
.
run_callback
(
store_result
,
q
.
get_nowait
)
gevent
.
sleep
(
0
)
assert
q
.
empty
(),
q
assert
q
.
full
(),
q
...
...
@@ -305,23 +325,23 @@ class TestNoWait(TestCase):
# put_nowait must work from the mainloop
def
test_put_nowait_unlock
(
self
):
result
=
[]
q
=
queue
.
Queue
(
0
)
q
=
queue
.
Queue
()
p
=
gevent
.
spawn
(
q
.
get
)
def
store_result
(
func
,
*
args
):
result
.
append
(
func
(
*
args
))
assert
q
.
empty
(),
q
assert
q
.
full
(),
q
assert
not
q
.
full
(),
q
gevent
.
sleep
(
0
)
assert
q
.
empty
(),
q
assert
q
.
full
(),
q
get_hub
().
loop
.
run_callback
(
store_result
,
util
.
wrap_errors
(
Exception
,
q
.
put_nowait
)
,
10
)
assert
not
q
.
full
(),
q
get_hub
().
loop
.
run_callback
(
store_result
,
q
.
put_nowait
,
10
)
assert
not
p
.
ready
(),
p
gevent
.
sleep
(
0
)
assert
result
==
[
None
],
result
assert
p
.
ready
(),
p
assert
q
.
full
(),
q
assert
not
q
.
full
(),
q
assert
q
.
empty
(),
q
...
...
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