Python Glossary Русский

all Python 3http.clientexception

http.client.ResponseNotReady

exceptions

getresponse() was called when there is nothing to wait for: no request has been sent, or the previous response has not been read yet. A subclass of ImproperConnectionState.

Syntax

except http.client.ResponseNotReady as e: ...

A common cause is a second getresponse() for the same request, or asking for a new response without read() on the previous one. The exception text is the connection state, usually 'Idle'. Network errors while reading a response look different: a drop before the status line is RemoteDisconnected, a timeout is TimeoutError.

Examples

import http.client
conn = http.client.HTTPConnection('example.com')
try:
    conn.getresponse()
except http.client.ResponseNotReady as e:
    print(repr(e))  # → ResponseNotReady('Idle')

See also

Open in the full glossarydocs.python.orgReport an inaccuracy