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
a6b9fe76
Commit
a6b9fe76
authored
Oct 08, 2009
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
socket: rst markup in docstrings and extend __all__
parent
1b245fe9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
18 deletions
+32
-18
gevent/socket.py
gevent/socket.py
+32
-18
No files found.
gevent/socket.py
View file @
a6b9fe76
...
...
@@ -20,7 +20,15 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
__all__
=
[
'GreenSocket'
,
'GreenFile'
,
'GreenPipe'
]
"""Cooperative socket module.
This module provides socket operations and some related functions.
The API of the functions and classes matches the API of the corresponding
items in standard :mod:`socket` module exactly, but the synchronous functions
in this module only block the current greenlet and let the others run.
"""
__all__
=
[
'socket'
,
'socketpair'
,
'fromfd'
,
'gethostbyname'
,
'getaddrinfo'
,
'getnameinfo'
,
'wrap_ssl'
]
import
_socket
_original_socket
=
_socket
.
socket
# XXX remove it
...
...
@@ -662,17 +670,19 @@ else:
def
gethostbyname
(
hostname
):
"""gethostbyname implemented using EvDNS.
Differs in the following ways:
- raises gaierror with EvDNS error codes instead of standard socket error codes
- does not support /etc/hosts (see code for hacks to make localhost work)
- does not iterate through all addresses, instead picks a random one each time
* raises gaierror with EvDNS error codes instead of standard socket error codes
* does not support /etc/hosts (see code for hacks to make localhost work)
* does not iterate through all addresses, instead picks a random one each time
"""
# TODO: this is supposed to iterate through all the addresses
# could use a global dict(hostname, iter)
# - fix these nasty hacks for localhost, ips, etc.
if
hostname
==
'localhost'
:
#
hack
if
hostname
==
'localhost'
:
#
QQQ should use /etc/hosts
return
'127.0.0.1'
if
_ip_re
.
match
(
hostname
):
# hack
if
_ip_re
.
match
(
hostname
):
return
hostname
if
hostname
==
_socket
.
gethostname
():
return
_socket
.
gethostbyname
(
hostname
)
...
...
@@ -685,14 +695,16 @@ else:
def
getaddrinfo
(
host
,
port
,
family
=
__socket__
.
AF_UNSPEC
,
socktype
=
__socket__
.
SOCK_STREAM
,
proto
=
0
,
flags
=
0
):
"""getaddrinfo implemented using EvDNS.
Differs in the following ways:
- raises gaierror with EvDNS error codes instead of standard socket error codes
- does not support /etc/hosts
- IPv6 support is untested.
- AF_UNSPEC only tries IPv4
- only supports TCP, UDP, IP protocols
- port must be numeric, does not support string service names. see socket.getservbyname
- only supported value for flags is core.DNS_QUERY_NO_SEARCH, see evdns.h
* raises gaierror with EvDNS error codes instead of standard socket error codes
* does not support /etc/hosts
* IPv6 support is untested.
* AF_UNSPEC only tries IPv4
* only supports TCP, UDP, IP protocols
* port must be numeric, does not support string service names. see socket.getservbyname
* only supported value for flags is core.DNS_QUERY_NO_SEARCH, see evdns.h
"""
if
_ip_re
.
match
(
host
):
return
[(
__socket__
.
AF_INET
,
socktype
,
p
,
''
,
(
host
,
port
))
for
p
in
(
6
,
17
,
0
)]
...
...
@@ -718,12 +730,14 @@ else:
def
getnameinfo
(
sockaddr
,
flags
):
"""getnameinfo implemented using EvDNS.
Differs in the following ways:
- raises gaierror with EvDNS error codes instead of standard socket error codes
- does not support /etc/hosts
- IPv6 support is untested.
- port must be numeric, does not support string service names. see socket.getservbyname
- only supported value for flags is core.DNS_QUERY_NO_SEARCH, see evdns.h
* raises gaierror with EvDNS error codes instead of standard socket error codes
* does not support /etc/hosts
* IPv6 support is untested.
* port must be numeric, does not support string service names. see socket.getservbyname
* only supported value for flags is core.DNS_QUERY_NO_SEARCH, see evdns.h
"""
# http://svn.python.org/view/python/trunk/Modules/socketmodule.c?view=markup
...
...
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