Skip to Content
Mastering Python Design Patterns - Second Edition
book

Mastering Python Design Patterns - Second Edition

by Kamon Ayeva, Sakis Kasampalis
August 2018
Intermediate to advanced
248 pages
5h 51m
English
Packt Publishing
Content preview from Mastering Python Design Patterns - Second Edition

A third example, using another third-party module

The third example uses the tenacity module. Since the retrying module has become unmaintained and there is the risk of it becoming obsolete, let's see another example where we will use its fork tenacity. We need to add the module using the pip install tenacity command. Also, the code we saw in the previous example should be updated at a couple of places. Let's see!

We replace the import for retrying module by the one for tenacity module, as follows:

import tenacity 

We replace the decorator as follows:

@tenacity.retrydef append_data_to_file(filename):    # code that could raise an exception 

With this new version of the code in the retry_write_file_tenacity_module.py file, testing it should give ...

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.
Start your free trial

You might also like

Learning Python Design Patterns - Second Edition - Second Edition

Learning Python Design Patterns - Second Edition - Second Edition

Chetan Giridhar, Gennadiy Zlobin

Publisher Resources

ISBN: 9781788837484Supplemental Content