nemo_gym.utils.http_deadline
nemo_gym.utils.http_deadline
An HTTP GET that ends at a total time limit.
Module Contents
Classes
Functions
API
The sockets of one request. shutdown ends any read blocked on them, and a socket opened afterwards.
Bases: HTTPAdapter
An adapter whose connections report their sockets, so that a request can be stopped from another thread.
GET url and return its status code and body, raising TimeoutError when timeout_s seconds have passed.
A requests timeout bounds the wait for each read, not the whole call: a peer that keeps sending a byte inside it,
in the headers or in the body, keeps the call going. The request therefore runs on a daemon thread that the caller
stops waiting for at the limit. At the limit the request’s sockets are shut down, which ends a read that is still
waiting, in the headers or in the body, so the thread and its connection are released promptly. With
read_body=False the body is not read and b"" is returned: for a readiness check, the answer is the headers.
Exceptions of the request, such as requests.ConnectionError, are raised unchanged.