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
88d2a6d0
Commit
88d2a6d0
authored
Oct 07, 2009
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gevent.socket: rename 'GreenSocket' to 'socket'
- the old 'GreenSocket' is still available as an alias
parent
ccfb0fe8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
11 deletions
+12
-11
gevent/socket.py
gevent/socket.py
+10
-9
greentest/test__refcount.py
greentest/test__refcount.py
+1
-1
greentest/test__socket_errors.py
greentest/test__socket_errors.py
+1
-1
No files found.
gevent/socket.py
View file @
88d2a6d0
...
...
@@ -139,7 +139,7 @@ _delegate_methods = ("recv", "recvfrom", "recv_into", "recvfrom_into", "send", "
timeout_default
=
object
()
class
GreenS
ocket
(
object
):
class
s
ocket
(
object
):
is_secure
=
False
# XXX remove this
def
__init__
(
self
,
family_or_realsock
=
_socket
.
AF_INET
,
*
args
,
**
kwargs
):
...
...
@@ -333,15 +333,16 @@ class GreenSocket(object):
def
gettimeout
(
self
):
return
self
.
timeout
GreenSocket
=
socket
# XXX this alias will be removed
SysCallError_code_mapping
=
{
-
1
:
8
}
class
GreenSSL
(
GreenS
ocket
):
class
GreenSSL
(
s
ocket
):
is_secure
=
True
def
__init__
(
self
,
fd
,
server_side
=
False
):
GreenS
ocket
.
__init__
(
self
,
fd
)
s
ocket
.
__init__
(
self
,
fd
)
self
.
_makefile_refs
=
0
if
server_side
:
self
.
fd
.
set_accept_state
()
...
...
@@ -389,7 +390,7 @@ class GreenSSL(GreenSocket):
raise
sslerror
(
str
(
ex
))
def
connect
(
self
,
*
args
):
GreenS
ocket
.
connect
(
self
,
*
args
)
s
ocket
.
connect
(
self
,
*
args
)
self
.
do_handshake
()
def
send
(
self
,
data
,
timeout
=
timeout_default
):
...
...
@@ -467,11 +468,11 @@ class GreenSSL(GreenSocket):
def
socketpair
(
*
args
):
one
,
two
=
_socket
.
socketpair
(
*
args
)
return
GreenSocket
(
one
),
GreenS
ocket
(
two
)
return
socket
(
one
),
s
ocket
(
two
)
def
fromfd
(
*
args
):
return
GreenS
ocket
(
_socket
.
fromfd
(
*
args
))
return
s
ocket
(
_socket
.
fromfd
(
*
args
))
def
socket_bind_and_listen
(
descriptor
,
addr
=
(
''
,
0
),
backlog
=
50
):
set_reuse_addr
(
descriptor
)
...
...
@@ -495,7 +496,7 @@ def tcp_listener(address, backlog=50):
which accepts connections forever and spawns greenlets for
each incoming connection.
"""
sock
=
GreenS
ocket
()
sock
=
s
ocket
()
socket_bind_and_listen
(
sock
,
address
,
backlog
=
backlog
)
return
sock
...
...
@@ -524,7 +525,7 @@ def connect_tcp(address, localaddr=None):
Create a TCP connection to address (host, port) and return the socket.
Optionally, bind to localaddr (host, port) first.
"""
desc
=
GreenS
ocket
()
desc
=
s
ocket
()
if
localaddr
is
not
None
:
desc
.
bind
(
localaddr
)
desc
.
connect
(
address
)
...
...
@@ -576,7 +577,7 @@ def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT):
af
,
socktype
,
proto
,
canonname
,
sa
=
res
sock
=
None
try
:
sock
=
GreenS
ocket
(
af
,
socktype
,
proto
)
sock
=
s
ocket
(
af
,
socktype
,
proto
)
if
timeout
is
not
_GLOBAL_DEFAULT_TIMEOUT
:
sock
.
settimeout
(
timeout
)
sock
.
connect
(
sa
)
...
...
greentest/test__refcount.py
View file @
88d2a6d0
...
...
@@ -19,7 +19,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
"""This test checks that socket instances (not
GreenSockets
but underlying sockets)
"""This test checks that socket instances (not
gevent.socket.socket
but underlying sockets)
are not leaked by the hub.
"""
from
gevent
import
monkey
...
...
greentest/test__socket_errors.py
View file @
88d2a6d0
...
...
@@ -25,7 +25,7 @@ from gevent import socket
class
TestSocketErrors
(
greentest
.
TestCase
):
def
test_connection_refused
(
self
):
s
=
socket
.
GreenS
ocket
()
s
=
socket
.
s
ocket
()
try
:
s
.
connect
((
'127.0.0.1'
,
81
))
except
socket
.
error
,
ex
:
...
...
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