Silence a deprecation warning by using the appropriate replacement construct

This commit is contained in:
Nick Coghlan 2009-10-18 10:29:10 +00:00
parent 2b06d42db5
commit f317019c07
1 changed files with 3 additions and 1 deletions

View File

@ -630,13 +630,15 @@ class TransientResource(object):
raise ResourceDenied("an optional resource is not available") raise ResourceDenied("an optional resource is not available")
@contextlib.contextmanager
def transient_internet(): def transient_internet():
"""Return a context manager that raises ResourceDenied when various issues """Return a context manager that raises ResourceDenied when various issues
with the Internet connection manifest themselves as exceptions.""" with the Internet connection manifest themselves as exceptions."""
time_out = TransientResource(IOError, errno=errno.ETIMEDOUT) time_out = TransientResource(IOError, errno=errno.ETIMEDOUT)
socket_peer_reset = TransientResource(socket.error, errno=errno.ECONNRESET) socket_peer_reset = TransientResource(socket.error, errno=errno.ECONNRESET)
ioerror_peer_reset = TransientResource(IOError, errno=errno.ECONNRESET) ioerror_peer_reset = TransientResource(IOError, errno=errno.ECONNRESET)
return contextlib.nested(time_out, socket_peer_reset, ioerror_peer_reset) with time_out, socket_peer_reset, ioerror_peer_reset:
yield
@contextlib.contextmanager @contextlib.contextmanager