- Mastering Concurrency in Python
- Quan Nguyen
- 245字
- 2021-06-10 19:24:09
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.
- Java 開發從入門到精通(第2版)
- Java 9 Concurrency Cookbook(Second Edition)
- 零基礎學Scratch少兒編程:小學課本中的Scratch創意編程
- Cassandra Design Patterns(Second Edition)
- Mastering Julia
- 人人都懂設計模式:從生活中領悟設計模式(Python實現)
- Windows Server 2016 Automation with PowerShell Cookbook(Second Edition)
- Oracle 18c 必須掌握的新特性:管理與實戰
- Integrating Facebook iOS SDK with Your Application
- Learning Concurrency in Kotlin
- 一塊面包板玩轉Arduino編程
- JavaScript腳本特效編程給力起飛
- Data Science Algorithms in a Week
- Mastering Apache Camel
- DB2SQL性能調優秘笈