mirror of https://github.com/python/cpython.git
bpo-34335: Use async/await syntax in documentation examples (GH-8674)
This commit is contained in:
parent
b221c93d4c
commit
d2ac400267
|
@ -431,8 +431,7 @@ Simple example querying HTTP headers of the URL passed on the command line::
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@asyncio.coroutine
|
async def print_http_headers(url):
|
||||||
def print_http_headers(url):
|
|
||||||
url = urllib.parse.urlsplit(url)
|
url = urllib.parse.urlsplit(url)
|
||||||
if url.scheme == 'https':
|
if url.scheme == 'https':
|
||||||
connect = asyncio.open_connection(url.hostname, 443, ssl=True)
|
connect = asyncio.open_connection(url.hostname, 443, ssl=True)
|
||||||
|
|
|
@ -392,8 +392,7 @@ function::
|
||||||
import asyncio.subprocess
|
import asyncio.subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@asyncio.coroutine
|
async def get_date():
|
||||||
def get_date():
|
|
||||||
code = 'import datetime; print(datetime.datetime.now())'
|
code = 'import datetime; print(datetime.datetime.now())'
|
||||||
|
|
||||||
# Create the subprocess, redirect the standard output into a pipe
|
# Create the subprocess, redirect the standard output into a pipe
|
||||||
|
|
Loading…
Reference in New Issue