官术网_书友最值得收藏!

Error handling

Error is something that no one can easily avoid in the field of programming, and this is especially true in making web requests. Errors in these programs can include making bad requests (invalid requests or even bad internet connections), mishandling downloaded HTML code, or unsuccessfully parsing HTML code. It is therefore important to make use of try...except blocks and other error-handling tools in Python to avoid crashing your application. Avoiding crashes is especially important if your code/applications are used in production and larger applications.

Specifically in concurrent web scraping, it might be possible for some threads to collect data successfully, while others fail. By implementing error-handling functionalities in multithreaded parts of your program, you can make sure that a failed thread will not be able to crash the entirety of your program and ensure that successful threads can still return their results.

However, it is important to note that blind error-catching is still undesirable. This term indicates the practice where we have a large try...expect block in our program that will catch any and all errors that occur in the program execution, and no further information regarding the errors can be obtained; this practice might also be known as error swallowing. It's highly recommended to have specific error handling code in a program, so that not only appropriate actions can be taken with regards to that specific error, but other errors that have not been taken into account might also reveal themselves.

主站蜘蛛池模板: 尖扎县| 五大连池市| 蒲城县| 苏尼特左旗| 梧州市| 沙田区| 望奎县| 漳浦县| 莲花县| 岳西县| 安溪县| 永昌县| 呈贡县| 凤凰县| 南汇区| 吉林省| 大化| 林芝县| 唐海县| 柯坪县| 沾益县| 盐山县| 江门市| 浏阳市| 娄烦县| 安丘市| 盐池县| 鄄城县| 丰原市| 乐平市| 周至县| 绩溪县| 遂宁市| 黄石市| 庆阳市| 昌平区| 苏尼特左旗| 闽清县| 孟津县| 会理县| 噶尔县|