Retry code throws "TypeError: 'Retrying' object is not iterable"

Bug #1934163 reported by Liam Young
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Snap Layer
Fix Committed
Undecided
Liam Young

Bug Description

Since 2f49ae75 the retry code is broken as the old version of tenacity does not support using tenacity.Retrying as an iterator

To reproduce it:

$ virtualenv /tmp/layer-snap-test
$ source /tmp/layer-snap-test/bin/activate
$ pip install 'tenacity<5.0.4'
$ ./test.py
Traceback (most recent call last):
  File "./test.py", line 5, in <module>
    for attempt in tenacity.Retrying():
TypeError: 'Retrying' object is not iterable

$ cat ./test.py
#!/usr/bin/env python

import tenacity

for attempt in tenacity.Retrying():
    with attempt:
        print("Hi!")

$ pip uninstall tenacity
Found existing installation: tenacity 5.0.3
Uninstalling tenacity-5.0.3:
  Would remove:
    /tmp/layer-snap-test/lib/python3.8/site-packages/tenacity-5.0.3.dist-info/*
    /tmp/layer-snap-test/lib/python3.8/site-packages/tenacity/*
Proceed (y/n)? y
  Successfully uninstalled tenacity-5.0.3

$ pip install tenacity
Collecting tenacity
  Using cached tenacity-7.0.0-py2.py3-none-any.whl (23 kB)
Requirement already satisfied: six>=1.9.0 in ./layer-snap-test/lib/python3.8/site-packages (from tenacity) (1.16.0)
Installing collected packages: tenacity
Successfully installed tenacity-7.0.0

$ ./test.py
Hi!

Related branches

Revision history for this message
Liam Young (gnuoy) wrote :

$ git diff 2f49ae75^ 2f49ae75
diff --git a/wheelhouse.txt b/wheelhouse.txt
index 48f8e12..f9bf12c 100644
--- a/wheelhouse.txt
+++ b/wheelhouse.txt
@@ -1 +1,4 @@
-tenacity
+# Newer versions of tenacity rely on `typing` which is in stdlib in
+# python3.5 but not python3.4. We want to continue to support
+# python3.4 (Trusty)
+tenacity<5.0.4

description: updated
Revision history for this message
Liam Young (gnuoy) wrote :
Revision history for this message
Aurelien Lourot (aurelien-lourot) wrote :
Changed in layer-snap:
status: New → Confirmed
Liam Young (gnuoy)
Changed in layer-snap:
status: Confirmed → Fix Committed
assignee: nobody → Liam Young (gnuoy)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.