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
fe4ea9cf
Commit
fe4ea9cf
authored
Oct 30, 2017
by
Quentin Dawans
Committed by
Yury Selivanov
Oct 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-31245: Asyncio unix socket datagram (#3164)
parent
a2314283
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
5 deletions
+24
-5
Doc/library/asyncio-eventloop.rst
Doc/library/asyncio-eventloop.rst
+4
-3
Lib/asyncio/base_events.py
Lib/asyncio/base_events.py
+6
-0
Lib/asyncio/events.py
Lib/asyncio/events.py
+2
-2
Lib/test/test_asyncio/test_base_events.py
Lib/test/test_asyncio/test_base_events.py
+11
-0
Misc/NEWS.d/next/Library/2017-08-22-11-05-35.bpo-31245.AniZuz.rst
...S.d/next/Library/2017-08-22-11-05-35.bpo-31245.AniZuz.rst
+1
-0
No files found.
Doc/library/asyncio-eventloop.rst
View file @
fe4ea9cf
...
...
@@ -341,9 +341,10 @@ Creating connections
.. coroutinemethod:: AbstractEventLoop.create_datagram_endpoint(protocol_factory, local_addr=None, remote_addr=None, \*, family=0, proto=0, flags=0, reuse_address=None, reuse_port=None, allow_broadcast=None, sock=None)
Create datagram connection: socket family :py:data:`~socket.AF_INET` or
:py:data:`~socket.AF_INET6` depending on *host* (or *family* if specified),
socket type :py:data:`~socket.SOCK_DGRAM`. *protocol_factory* must be a
Create datagram connection: socket family :py:data:`~socket.AF_INET`,
:py:data:`~socket.AF_INET6` or :py:data:`~socket.AF_UNIX` depending on
*host* (or *family* if specified), socket type
:py:data:`~socket.SOCK_DGRAM`. *protocol_factory* must be a
callable returning a :ref:`protocol <asyncio-protocol>` instance.
This method is a :ref:`coroutine <coroutine>` which will try to
...
...
Lib/asyncio/base_events.py
View file @
fe4ea9cf
...
...
@@ -859,6 +859,12 @@ class BaseEventLoop(events.AbstractEventLoop):
if
family
==
0
:
raise
ValueError
(
'unexpected address family'
)
addr_pairs_info
=
(((
family
,
proto
),
(
None
,
None
)),)
elif
hasattr
(
socket
,
'AF_UNIX'
)
and
family
==
socket
.
AF_UNIX
:
for
addr
in
(
local_addr
,
remote_addr
):
if
addr
is
not
None
and
not
isistance
(
addr
,
str
):
raise
TypeError
(
'string is expected'
)
addr_pairs_info
=
(((
family
,
proto
),
(
local_addr
,
remote_addr
)),
)
else
:
# join address by (family, protocol)
addr_infos
=
collections
.
OrderedDict
()
...
...
Lib/asyncio/events.py
View file @
fe4ea9cf
...
...
@@ -378,8 +378,8 @@ class AbstractEventLoop:
protocol_factory must be a callable returning a protocol instance.
socket family AF_INET
or socket.AF_INET6 depending on host (or
family if specified), socket type SOCK_DGRAM.
socket family AF_INET
, socket.AF_INET6 or socket.AF_UNIX depending on
host (or
family if specified), socket type SOCK_DGRAM.
reuse_address tells the kernel to reuse a local socket in
TIME_WAIT state, without waiting for its natural timeout to
...
...
Lib/test/test_asyncio/test_base_events.py
View file @
fe4ea9cf
...
...
@@ -1528,6 +1528,17 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
self
.
loop
.
run_until_complete
(
protocol
.
done
)
self
.
assertEqual
(
'CLOSED'
,
protocol
.
state
)
@
unittest
.
skipUnless
(
hasattr
(
socket
,
'AF_UNIX'
),
'No UNIX Sockets'
)
def
test_create_datagram_endpoint_sock_unix
(
self
):
fut
=
self
.
loop
.
create_datagram_endpoint
(
lambda
:
MyDatagramProto
(
create_future
=
True
,
loop
=
self
.
loop
),
family
=
socket
.
AF_UNIX
)
transport
,
protocol
=
self
.
loop
.
run_until_complete
(
fut
)
assert
transport
.
_sock
.
family
==
socket
.
AF_UNIX
transport
.
close
()
self
.
loop
.
run_until_complete
(
protocol
.
done
)
self
.
assertEqual
(
'CLOSED'
,
protocol
.
state
)
def
test_create_datagram_endpoint_sock_sockopts
(
self
):
class
FakeSock
:
type
=
socket
.
SOCK_DGRAM
...
...
Misc/NEWS.d/next/Library/2017-08-22-11-05-35.bpo-31245.AniZuz.rst
0 → 100644
View file @
fe4ea9cf
Added support for AF_UNIX socket in asyncio `create_datagram_endpoint`.
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