August 2018
Intermediate to advanced
248 pages
5h 51m
English
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 ...