20.4 Exception Groups
Exception handling, as discussed in the previous sections of this chapter, imposes a key requirement on the code: Only a single exception can be raised and caught at any given time.
This requirement is usually not a problem, which is why classic exception handling is perfectly adequate for many Python programs. However, there are special situations in which you must deviate from this principle. To illustrate this, consider the following two situations:
-
An image-processing program performs image transformation on several images simultaneously. The program starts the parallel operations and then waits for all images to be processed. An individual operation may fail with an exception—for example, because a file could ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access