Nohup Requests

Send detached requests that are processed in the background

Similar to Unix's nohup command, nohup requests are sent in the background.

Adding the nohup=True keyword argument will return a LazyTLSRequest object. This will send the request immediately, but doesn't wait for the response to be ready until an attribute of the response is accessed.

resp1 = hrequests.get('https://www.google.com/', nohup=True)
resp2 = hrequests.get('https://www.google.com/', nohup=True)

resp1 and resp2 are sent concurrently. They will never pause the current thread, unless an attribute of the response is accessed:

print('Resp 1:', resp1.reason)  # will wait for resp1 to finish, if it hasn't already
print('Resp 2:', resp2.reason)  # will wait for resp2 to finish, if it hasn't already

This is useful for sending requests in the background that aren't needed until later.

Note: In nohup, a new thread is created for each request. For larger scale concurrency, please consider the following:

Last updated