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
459fe269
Commit
459fe269
authored
May 30, 2011
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update tests with regard to removal of tcp_listener and bind_socket_and_listen from gevent.socket
parent
0dabcf6b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
6 deletions
+25
-6
greentest/greentest.py
greentest/greentest.py
+19
-0
greentest/test__greenio.py
greentest/test__greenio.py
+4
-4
greentest/test__socket.py
greentest/test__socket.py
+2
-2
No files found.
greentest/greentest.py
View file @
459fe269
...
...
@@ -372,3 +372,22 @@ def walk_modules(basedir=None, modpath=None, include_so=False):
yield
path
,
modpath
+
fn
[:
-
5
]
else
:
yield
path
,
modpath
+
fn
[:
-
3
]
def
bind_and_listen
(
sock
,
address
=
(
''
,
0
),
backlog
=
50
,
reuse_addr
=
True
):
from
socket
import
SOL_SOCKET
,
SO_REUSEADDR
,
error
if
reuse_addr
:
try
:
sock
.
setsockopt
(
SOL_SOCKET
,
SO_REUSEADDR
,
sock
.
getsockopt
(
SOL_SOCKET
,
SO_REUSEADDR
)
|
1
)
except
error
:
pass
sock
.
bind
(
address
)
sock
.
listen
(
backlog
)
def
tcp_listener
(
address
,
backlog
=
50
,
reuse_addr
=
True
):
"""A shortcut to create a TCP socket, bind it and put it into listening state."""
from
gevent
import
socket
sock
=
socket
.
socket
()
bind_and_listen
(
sock
)
return
sock
greentest/test__greenio.py
View file @
459fe269
...
...
@@ -17,7 +17,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
from
greentest
import
TestCase
,
main
from
greentest
import
TestCase
,
main
,
tcp_listener
import
gevent
from
gevent
import
socket
...
...
@@ -65,12 +65,12 @@ class TestGreenIo(TestCase):
assert
fd
.
read
()
==
''
fd
.
close
()
server
=
socket
.
tcp_listener
((
'0.0.0.0'
,
0
))
server
=
tcp_listener
((
'0.0.0.0'
,
0
))
server_greenlet
=
gevent
.
spawn
(
accept_close_early
,
server
)
did_it_work
(
server
)
server_greenlet
.
kill
()
server
=
socket
.
tcp_listener
((
'0.0.0.0'
,
0
))
server
=
tcp_listener
((
'0.0.0.0'
,
0
))
server_greenlet
=
gevent
.
spawn
(
accept_close_late
,
server
)
did_it_work
(
server
)
server_greenlet
.
kill
()
...
...
@@ -92,7 +92,7 @@ class TestGreenIo(TestCase):
finally
:
listener
.
close
()
server
=
socket
.
tcp_listener
((
'0.0.0.0'
,
0
))
server
=
tcp_listener
((
'0.0.0.0'
,
0
))
gevent
.
spawn
(
accept_once
,
server
)
client
=
socket
.
create_connection
((
'127.0.0.1'
,
server
.
getsockname
()[
1
]))
fd
=
client
.
makefile
()
...
...
greentest/test__socket.py
View file @
459fe269
...
...
@@ -12,7 +12,7 @@ class TestTCP(greentest.TestCase):
def
setUp
(
self
):
greentest
.
TestCase
.
setUp
(
self
)
self
.
listener
=
socke
t
.
tcp_listener
((
'127.0.0.1'
,
0
))
self
.
listener
=
greentes
t
.
tcp_listener
((
'127.0.0.1'
,
0
))
def
tearDown
(
self
):
del
self
.
listener
...
...
@@ -127,7 +127,7 @@ if hasattr(socket, 'ssl'):
import
_socket
r
=
_socket
.
socket
()
sock
=
socket
.
ssl
(
r
,
private_key
,
certificate
)
socke
t
.
bind_and_listen
(
sock
,
address
)
greentes
t
.
bind_and_listen
(
sock
,
address
)
return
sock
...
...
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