summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2016-09-30 15:18:34 (GMT)
committerGuido van Rossum <guido@python.org>2016-09-30 15:18:34 (GMT)
commit0035be3fee832ebccd8c86576b9c604ca321cefa (patch)
tree4622d6c8636aa54e1aee845cd9bdb394b54e537b /Lib/asyncio
parent61cd726d1abca5601f85d0029466ab9ec3216cc0 (diff)
parente3c65a7a228a5808a7af48a47fdd77e982f95d00 (diff)
downloadcpython-0035be3fee832ebccd8c86576b9c604ca321cefa.zip
cpython-0035be3fee832ebccd8c86576b9c604ca321cefa.tar.gz
cpython-0035be3fee832ebccd8c86576b9c604ca321cefa.tar.bz2
Misc asyncio improvements from upstream (merge 3.5->3.6)
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/base_events.py28
-rw-r--r--Lib/asyncio/base_subprocess.py1
-rw-r--r--Lib/asyncio/coroutines.py4
-rw-r--r--Lib/asyncio/queues.py1
-rw-r--r--Lib/asyncio/tasks.py4
5 files changed, 16 insertions, 22 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index ac6e8f2..86b4291 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -115,24 +115,16 @@ def _ipaddr_info(host, port, family, type, proto):
if port is None:
port = 0
- elif isinstance(port, bytes):
- if port == b'':
- port = 0
- else:
- try:
- port = int(port)
- except ValueError:
- # Might be a service name like b"http".
- port = socket.getservbyname(port.decode('ascii'))
- elif isinstance(port, str):
- if port == '':
- port = 0
- else:
- try:
- port = int(port)
- except ValueError:
- # Might be a service name like "http".
- port = socket.getservbyname(port)
+ elif isinstance(port, bytes) and port == b'':
+ port = 0
+ elif isinstance(port, str) and port == '':
+ port = 0
+ else:
+ # If port's a service name like "http", don't skip getaddrinfo.
+ try:
+ port = int(port)
+ except (TypeError, ValueError):
+ return None
if family == socket.AF_UNSPEC:
afs = [socket.AF_INET, socket.AF_INET6]
diff --git a/Lib/asyncio/base_subprocess.py b/Lib/asyncio/base_subprocess.py
index 28482b7..a00d9d5 100644
--- a/Lib/asyncio/base_subprocess.py
+++ b/Lib/asyncio/base_subprocess.py
@@ -3,7 +3,6 @@ import subprocess
import warnings
from . import compat
-from . import futures
from . import protocols
from . import transports
from .coroutines import coroutine
diff --git a/Lib/asyncio/coroutines.py b/Lib/asyncio/coroutines.py
index e013d64..5cecc76 100644
--- a/Lib/asyncio/coroutines.py
+++ b/Lib/asyncio/coroutines.py
@@ -120,8 +120,8 @@ class CoroWrapper:
def send(self, value):
return self.gen.send(value)
- def throw(self, exc):
- return self.gen.throw(exc)
+ def throw(self, type, value=None, traceback=None):
+ return self.gen.throw(type, value, traceback)
def close(self):
return self.gen.close()
diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py
index c453f02..2d38972 100644
--- a/Lib/asyncio/queues.py
+++ b/Lib/asyncio/queues.py
@@ -7,7 +7,6 @@ import heapq
from . import compat
from . import events
-from . import futures
from . import locks
from .coroutines import coroutine
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index 4c66546..f735b44 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -594,6 +594,10 @@ def gather(*coros_or_futures, loop=None, return_exceptions=False):
"""Return a future aggregating results from the given coroutines
or futures.
+ Coroutines will be wrapped in a future and scheduled in the event
+ loop. They will not necessarily be scheduled in the same order as
+ passed in.
+
All futures must share the same event loop. If all the tasks are
done successfully, the returned future's result is the list of
results (in the order of the original sequence, not necessarily