Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Mastering Python Design Patterns
  • Table Of Contents Toc
  • Feedback & Rating feedback
Mastering Python Design Patterns

Mastering Python Design Patterns

By : Kamon Ayeva, Kasampalis, Sakis Kasampalis
4.3 (8)
close
close
Mastering Python Design Patterns

Mastering Python Design Patterns

4.3 (8)
By: Kamon Ayeva, Kasampalis, Sakis Kasampalis

Overview of this book

As software systems become increasingly complex, maintaining code quality, scalability, and efficiency can be a daunting challenge. Mastering Python Design Patterns is an essential resource that equips you with the tools you need to overcome these hurdles and create robust, scalable applications. The book delves into design principles and patterns in Python, covering both classic and modern patterns, and apply them to solve daily challenges as a Python developer or architect. Co-authored by two Python experts with a combined experience of three decades, this new edition covers creational, structural, behavioral, and architectural patterns, including concurrency, asynchronous, and performance patterns. You'll find out how these patterns are relevant to various domains, such as event handling, concurrency, distributed systems, and testing. Whether you're working on user interfaces (UIs), web apps, APIs, data pipelines, or AI models, this book equips you with the knowledge to build robust and maintainable software. The book also presents Python anti-patterns, helping you avoid common pitfalls and ensuring your code remains clean and efficient. By the end of this book, you'll be able to confidently apply classic and modern Python design patterns to build robust, scalable applications.
Table of Contents (17 chapters)
close
close
Free Chapter
1
Part 1: Start with Principles
4
Part 2: From the Gang of Four
8
Part 3: Beyond the Gang of Four

The Circuit Breaker pattern

One approach to FT involves retries, as we have just seen. But, when a failure due to communication with an external component is likely to be long-lasting, using a retry mechanism can affect the responsiveness of the application. We might be wasting time and resources trying to repeat a request that’s likely to fail. This is where another pattern can be useful: the Circuit Breaker pattern.

With the Circuit Breaker pattern, you wrap a fragile function call, or an integration point with an external service, in a special (circuit breaker) object, which monitors for failures. Once the failures reach a certain threshold, the circuit breaker trips and all subsequent calls to the circuit breaker return with an error, without the protected call being made at all.

Real-world examples

In life, we can think of a water or electricity distribution circuit where a circuit breaker plays an important role.

In software, a circuit breaker is used in the...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY