February 2019
Intermediate to advanced
672 pages
16h 50m
English
In addition to different options for status codes, the httpstat.us website additionally provides a way to simulate a delay in its response when we send in requests. Specifically, we can customize the delay time (in milliseconds) with a query argument in our GET request. For example, httpstat.us/200?sleep=5000 will return a response after five seconds of delay.
Now, let us see how a delay like this would affect the execution of our program. Consider the Chapter12/example5.py file, which contains the current request logic of our ping test application but has a different URL list:
# Chapter12/example5.pyimport threadingimport requestsclass MyThread(threading.Thread): def __init__(self, url): ...