Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d143209d
Commit
d143209d
authored
Jun 19, 2014
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tulip issue 83: document more asyncio functions in docstrings
parent
54c4b8e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
11 deletions
+58
-11
Doc/library/asyncio-eventloop.rst
Doc/library/asyncio-eventloop.rst
+3
-4
Lib/asyncio/base_events.py
Lib/asyncio/base_events.py
+18
-3
Lib/asyncio/selector_events.py
Lib/asyncio/selector_events.py
+37
-4
No files found.
Doc/library/asyncio-eventloop.rst
View file @
d143209d
...
...
@@ -311,11 +311,10 @@ Creating listening connections
.. method:: BaseEventLoop.create_server(protocol_factory, host=None, port=None, \*, family=socket.AF_UNSPEC, flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None, reuse_address=None)
A :ref:`coroutine <coroutine>` method which creates a TCP server bound to
host and port
.
Create a TCP server bound to host and port. Return an
:class:`AbstractServer` object which can be used to stop the service
.
The return value is a :class:`AbstractServer` object which can be used to stop
the service.
This method is a :ref:`coroutine <coroutine>`.
If *host* is an empty string or None all interfaces are assumed
and a list of multiple sockets will be returned (most likely
...
...
Lib/asyncio/base_events.py
View file @
d143209d
...
...
@@ -320,7 +320,7 @@ class BaseEventLoop(events.AbstractEventLoop):
"than the current one"
)
def
call_soon_threadsafe
(
self
,
callback
,
*
args
):
"""
XXX
"""
"""
Like call_soon(), but thread safe.
"""
handle
=
self
.
_call_soon
(
callback
,
args
,
check_loop
=
False
)
self
.
_write_to_self
()
return
handle
...
...
@@ -358,7 +358,17 @@ class BaseEventLoop(events.AbstractEventLoop):
def
create_connection
(
self
,
protocol_factory
,
host
=
None
,
port
=
None
,
*
,
ssl
=
None
,
family
=
0
,
proto
=
0
,
flags
=
0
,
sock
=
None
,
local_addr
=
None
,
server_hostname
=
None
):
"""XXX"""
"""Connect to a TCP server.
Create a streaming transport connection to a given Internet host and
port: socket family AF_INET or socket.AF_INET6 depending on host (or
family if specified), socket type SOCK_STREAM. protocol_factory must be
a callable returning a protocol instance.
This method is a coroutine which will try to establish the connection
in the background. When successful, the coroutine returns a
(transport, protocol) pair.
"""
if
server_hostname
is
not
None
and
not
ssl
:
raise
ValueError
(
'server_hostname is only meaningful with ssl'
)
...
...
@@ -557,7 +567,12 @@ class BaseEventLoop(events.AbstractEventLoop):
backlog
=
100
,
ssl
=
None
,
reuse_address
=
None
):
"""XXX"""
"""Create a TCP server bound to host and port.
Return an AbstractServer object which can be used to stop the service.
This method is a coroutine.
"""
if
isinstance
(
ssl
,
bool
):
raise
TypeError
(
'ssl argument must be an SSLContext or None'
)
if
host
is
not
None
or
port
is
not
None
:
...
...
Lib/asyncio/selector_events.py
View file @
d143209d
...
...
@@ -226,7 +226,14 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
return
False
def
sock_recv
(
self
,
sock
,
n
):
"""XXX"""
"""Receive data from the socket.
The return value is a bytes object representing the data received.
The maximum amount of data to be received at once is specified by
nbytes.
This method is a coroutine.
"""
fut
=
futures
.
Future
(
loop
=
self
)
self
.
_sock_recv
(
fut
,
False
,
sock
,
n
)
return
fut
...
...
@@ -253,7 +260,16 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
fut
.
set_result
(
data
)
def
sock_sendall
(
self
,
sock
,
data
):
"""XXX"""
"""Send data to the socket.
The socket must be connected to a remote socket. This method continues
to send data from data until either all data has been sent or an
error occurs. None is returned on success. On error, an exception is
raised, and there is no way to determine how much data, if any, was
successfully processed by the receiving end of the connection.
This method is a coroutine.
"""
fut
=
futures
.
Future
(
loop
=
self
)
if
data
:
self
.
_sock_sendall
(
fut
,
False
,
sock
,
data
)
...
...
@@ -285,7 +301,16 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
self
.
add_writer
(
fd
,
self
.
_sock_sendall
,
fut
,
True
,
sock
,
data
)
def
sock_connect
(
self
,
sock
,
address
):
"""XXX"""
"""Connect to a remote socket at address.
The address must be already resolved to avoid the trap of hanging the
entire event loop when the address requires doing a DNS lookup. For
example, it must be an IP address, not an hostname, for AF_INET and
AF_INET6 address families. Use getaddrinfo() to resolve the hostname
asynchronously.
This method is a coroutine.
"""
fut
=
futures
.
Future
(
loop
=
self
)
try
:
base_events
.
_check_resolved_address
(
sock
,
address
)
...
...
@@ -318,7 +343,15 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
fut
.
set_result
(
None
)
def
sock_accept
(
self
,
sock
):
"""XXX"""
"""Accept a connection.
The socket must be bound to an address and listening for connections.
The return value is a pair (conn, address) where conn is a new socket
object usable to send and receive data on the connection, and address
is the address bound to the socket on the other end of the connection.
This method is a coroutine.
"""
fut
=
futures
.
Future
(
loop
=
self
)
self
.
_sock_accept
(
fut
,
False
,
sock
)
return
fut
...
...
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