Skip to content
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

Drop aiohttp.Timeout #2370

Merged
merged 2 commits into from
Oct 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGES/2348.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop `aiohttp.Timeout` and use `async_timeout.timeout` instead.
8 changes: 5 additions & 3 deletions aiohttp/client_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import asyncio
import json

import async_timeout

from .client_exceptions import ClientError
from .helpers import PY_352, Timeout, call_later, create_future
from .helpers import PY_352, call_later, create_future
from .http import (WS_CLOSED_MESSAGE, WS_CLOSING_MESSAGE, WebSocketError,
WSMessage, WSMsgType)

Expand Down Expand Up @@ -153,7 +155,7 @@ def close(self, *, code=1000, message=b''):

while True:
try:
with Timeout(self._timeout, loop=self._loop):
with async_timeout.timeout(self._timeout, loop=self._loop):
msg = yield from self._reader.read()
except asyncio.CancelledError:
self._close_code = 1006
Expand Down Expand Up @@ -188,7 +190,7 @@ def receive(self, timeout=None):
try:
self._waiting = create_future(self._loop)
try:
with Timeout(
with async_timeout.timeout(
timeout or self._receive_timeout,
loop=self._loop):
msg = yield from self._reader.read()
Expand Down
7 changes: 3 additions & 4 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from urllib.parse import quote
from urllib.request import getproxies

from async_timeout import timeout
import async_timeout
from yarl import URL

from . import hdrs
Expand All @@ -31,11 +31,10 @@
PY_352 = sys.version_info >= (3, 5, 2)


__all__ = ('BasicAuth', 'Timeout')
__all__ = ('BasicAuth',)


sentinel = object()
Timeout = timeout
NO_EXTENSIONS = bool(os.environ.get('AIOHTTP_NO_EXTENSIONS'))

CHAR = set(chr(i) for i in range(0, 128))
Expand Down Expand Up @@ -711,7 +710,7 @@ def timeout(self):
self._cancelled = True


class CeilTimeout(Timeout):
class CeilTimeout(async_timeout.timeout):

def __enter__(self):
if self._timeout is not None:
Expand Down
8 changes: 5 additions & 3 deletions aiohttp/web_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import json
from collections import namedtuple

import async_timeout

from . import hdrs
from .helpers import PY_352, Timeout, call_later, create_future
from .helpers import PY_352, call_later, create_future
from .http import (WS_CLOSED_MESSAGE, WS_CLOSING_MESSAGE, HttpProcessingError,
WebSocketError, WebSocketReader, WSMessage, WSMsgType,
do_handshake)
Expand Down Expand Up @@ -234,7 +236,7 @@ def close(self, *, code=1000, message=b''):
return True

try:
with Timeout(self._timeout, loop=self._loop):
with async_timeout.timeout(self._timeout, loop=self._loop):
msg = yield from self._reader.read()
except asyncio.CancelledError:
self._close_code = 1006
Expand Down Expand Up @@ -275,7 +277,7 @@ def receive(self, timeout=None):
try:
self._waiting = create_future(self._loop)
try:
with Timeout(
with async_timeout.timeout(
timeout or self._receive_timeout, loop=self._loop):
msg = yield from self._reader.read()
self._reset_heartbeat()
Expand Down