Py3.7 RuntimeError: generator raised StopIteration

Bug #1780823 reported by Corey Bryant
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
taskflow
Invalid
High
Unassigned

Bug Description

Running cinder unit tests I hit the following:

https://paste.ubuntu.com/p/yc2t8WVCGS/

File "/usr/lib/python3/dist-packages/taskflow/engines/action_engine/engine.py", line 247,in run
    for _state in self.run_iter(timeout=timeout):
RuntimeError: generator raised StopIteration

I believe this is due to changes introduced by https://www.python.org/dev/peps/pep-0479/.

I attached a quick patch that may fix it (?).

Revision history for this message
Corey Bryant (corey.bryant) wrote :
Revision history for this message
Corey Bryant (corey.bryant) wrote :

This appears to be more complex than expected. With the approach mentioned in the original patch that was attached to this bug, StopIteration ends up in the revert failures dict and gets re-raised when the following code is executed:

r_failures = self.storage.get_revert_failures()
er_failures = itertools.chain(
    six.itervalues(e_failures),
    six.itervalues(r_failures))
failure.Failure.reraise_if_any(er_failures)

Revision history for this message
Corey Bryant (corey.bryant) wrote :

Could potentially loop through r_failures and drop any occurrences of StopIteration before calling itertools.chain() and reraise_if_any().

Ben Nemec (bnemec)
Changed in taskflow:
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Corey Bryant (corey.bryant) wrote :

Would love to get a hand with fixing this in stein if anyone has cycles. There are a lot of py3.7 issues across openstack and we'll need a hand with some of them.

Revision history for this message
Sean McGinnis (sean-mcginnis) wrote :

Not going to dupe for now, but here is a bug tracking this in Cinder:

https://bugs.launchpad.net/cinder/+bug/1795957

Not sure yet if fixing this in Taskflow will resolve it or not, so keeping separate in case any additional work is needed there.

Revision history for this message
Ben Nemec (bnemec) wrote :

Looking a little closer at this, I'm not clear that this is a problem in Taskflow. The StopIteration is actually being raised from mock, which suggests to me that we have a mock with insufficient side_effects for the calls being made. I think this may be one of the subtle bugs that were previously getting masked by the silent handling of StopIteration.

Changed in taskflow:
status: Confirmed → Incomplete
Revision history for this message
Sean McGinnis (sean-mcginnis) wrote :

There are a few locations (at least two IIRC) in the taskflow code where StopIteration is being raised. So the Cinder issue may be something in Cinder, but there likely is some work required in taskflow to be fully py3.7 safe.

Revision history for this message
Ben Nemec (bnemec) wrote :

AFAICT, the places we're raising StopIteration in taskflow are valid. The only problem is raising StopIteration out of a generator, which we aren't doing.

Changed in taskflow:
status: Incomplete → Invalid
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.