December 2018
Beginner to intermediate
796 pages
19h 54m
English
Most, if not all, libraries that expose functions to make HTTP requests, provide the ability to specify a timeout when performing the request. This means that if after X seconds (X being the timeout), the request hasn't completed, the whole operation is aborted and execution resumes from the next instruction. Not all functions expose this feature though, so, when a function doesn't provide the ability to being interrupted, we can use a process to simulate that behavior. In this example, we'll be trying to translate a hostname into an IPv4 address.
The gethostbyname function, from the socket module, doesn't allow us to put a timeout on the operation though, so we use a process to do that ...
Read now
Unlock full access