8000 Phase 2 of async/await by gvanrossum · Pull Request #1946 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Phase 2 of async/await #1946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Aug 3, 2016
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove no-op @asyncio.coroutine decorators.
  • Loading branch information
Guido van Rossum committed Aug 3, 2016
commit fc2fd88626b0656b4193cc0b13661c6022d74de7
12 changes: 0 additions & 12 deletions test-data/samples/crawl2.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ def close(self) -> None:
self.connections.clear()
self.queue.clear()

@asyncio.coroutine
async def get_connection(self, host: str, port: int, ssl: bool) -> 'Connection':
"""Create or reuse a connection."""
port = port or (443 if ssl else 80)
Expand Down Expand Up @@ -253,7 +252,6 @@ def fileno(self) -> Optional[int]:
return sock.fileno()
return None

@asyncio.coroutine
async def connect(self) -> None:
self.reader, self.writer = await asyncio.open_connection(
self.host, self.port, ssl=self.ssl)
E 8000 xpand Down Expand Up @@ -301,7 +299,6 @@ def __init__(self, log: Logger, url: str, pool: ConnectionPool) -> None:
self.headers = [] # type: List[Tuple[str, str]]
self.conn = None # type: Connection

@asyncio.coroutine
async def connect(self) -> None:
"""Open a connection to the server."""
self.log(1, '* Connecting to %s:%s using %s for %s' %
Expand All @@ -319,7 +316,6 @@ def close(self, recycle: bool = False) -> None:
self.conn.close(recycle)
self.conn = None

@asyncio.coroutine
async def putline(self, line: str) -> None:
"""Write a line to the connection.

Expand All @@ -328,7 +324,6 @@ async def putline(self, line: str) -> None:
self.log(2, '>', line)
self.conn.writer.write(line.encode('latin-1') + b'\r\n')

@asyncio.coroutine
async def send_request(self) -> None:
"""Send the request."""
request_line = '%s %s %s' % (self.method, self.full_path,
Expand All @@ -344,7 +339,6 @@ async def send_request(self) -> None:
await self.putline(line)
await self.putline('')

@asyncio.coroutine
async def get_response(self) -> 'Response':
"""Receive the response."""
response = Response(self.log, self.conn.reader)
Expand All @@ -368,14 +362,12 @@ def __init__(self, log: Logger, reader: asyncio.StreamReader) -> None:
self.reason = None # type: str # 'Ok'
self.headers = [] # type: List[Tuple[str, str]] # [('Content-Type', 'text/html')]

@asyncio.coroutine
async def getline(self) -> str:
"""Read one line from the connection."""
line = (await self.reader.readline()).decode('latin-1').rstrip()
self.log(2, '<', line)
return line

@asyncio.coroutine
async def read_headers(self) -> None:
"""Read the response status and the request headers."""
status_line = await self.getline()
Expand Down Expand Up @@ -407,7 +399,6 @@ def get_header(self, key: str, default: str = '') -> str:
return v
return default

@asyncio.coroutine
async def read(self) -> bytes:
"""Read the response body.

Expand Down Expand Up @@ -490,7 +481,6 @@ def __init__(self, log: Logger, url: str, crawler: 'Crawler',
self.urls = None # type: Set[str]
self.new_urls = None # type: Set[str]

@asyncio.coroutine
async def fetch(self) -> None:
"""Attempt to fetch the contents of the URL.

Expand Down Expand Up @@ -744,7 +734,6 @@ def add_url(self, url: str, max_redirect: int = None) -> bool:
self.todo[url] = max_redirect
return True

@asyncio.coroutine
async def crawl(self) -> None:
"""Run the crawler until all finished."""
with (await self.termination):
Expand All @@ -762,7 +751,6 @@ async def crawl(self) -> None:
await self.termination.wait()
self.t1 = time.time()

@asyncio.coroutine
async def fetch(self, fetcher: Fetcher) -> None:
"""Call the Fetcher's fetch(), with a limit on concurrency.

Expand Down
0