Handle PEP479

This work is part of debian intergration effort.
On CentOS 7 software is run mostly using Python 2.7.5 and few components
are run using Python 3.6.8.
On Debian Bullseye software is run using Python 3.9.2.

Starting with Python 3.7 the generators logic was slightly changed.
Details are presented in PEP479[1].
PEP479 prevents bootstrap from finishing on Debian.
Raised StopIteration exceptions in generators are now intercepted and
re-raised as RuntimeError exceptions, which breaks the existing logic.
Generators will stop when a None element is encountered, so a plain
'return' statement will obtain the desired effect.

Out of context test code:
"""
def iterconsume(limit=None, timeout=None):
    for iteration in range(1,5):
        if limit and iteration >= limit:
            return  # replace 'raise StopIteration'
        yield iteration

it = iterconsume(limit=2)
while True:
    try:
        print(next(it))
    except StopIteration:
        print('STOP')
        break
"""

CentOS 7 tests:
PASS: Out of context code snippets using py2.7 and py3.6
PASS: Build & install
PASS: Bootstrap
PASS: Unlocked enabled available
PASS: Apps are auto-installed (platform-integ-apps)
PASS: Compared sysinv log with 1st Dec load, nothing unsusual

Debian Bullseye tests:
PASS: Out of context code snippets using py3.9
PASS: Build & install
PASS: Bootstrap goes past the breaking point

[1] https://www.python.org/dev/peps/pep-0479/

Story: 2009101
Task: 44333
Signed-off-by: Dan Voiculeasa <dan.voiculeasa@windriver.com>
Change-Id: I6180acebf80de7a483015a3986898c5fbf41d341
This commit is contained in:
Dan Voiculeasa 2022-01-20 10:08:31 +02:00
parent 93c9bb961d
commit 22f6fa6c64
4 changed files with 11 additions and 14 deletions

View File

@ -1,4 +1,4 @@
# Copyright 2013-2021 Wind River, Inc.
# Copyright 2013-2022 Wind River, Inc.
# Copyright 2012 Openstack Foundation
# All Rights Reserved.
#
@ -586,4 +586,4 @@ class ResponseBodyIterator(object):
if chunk:
return chunk
else:
raise StopIteration()
return

View File

@ -1,5 +1,4 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2022 Wind River Systems, Inc
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
@ -495,7 +494,7 @@ class MulticallProxyWaiter(object):
def __iter__(self):
"""Return a result until we get a reply with an 'ending" flag"""
if self._done:
raise StopIteration
return
while True:
result = None
try:
@ -510,7 +509,7 @@ class MulticallProxyWaiter(object):
if self._got_ending:
yield result
self.done()
raise StopIteration
return
if isinstance(result, Exception):
self.done()
raise result # pylint: disable=raising-bad-type
@ -553,7 +552,7 @@ class MulticallWaiter(object):
def __iter__(self):
"""Return a result until we get a 'None' response from consumer"""
if self._done:
raise StopIteration
return
while True:
try:
next(self._iterator)
@ -562,7 +561,7 @@ class MulticallWaiter(object):
self.done()
if self._got_ending:
self.done()
raise StopIteration
return
result = self._result
if isinstance(result, Exception):
self.done()

View File

@ -1,5 +1,4 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2022 Wind River Systems, Inc
# Copyright 2011 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -662,7 +661,7 @@ class Connection(object):
for iteration in itertools.count(0):
if limit and iteration >= limit:
raise StopIteration
return
yield self.ensure(_error_callback, _consume)
def cancel_consumer_thread(self):

View File

@ -1,5 +1,4 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2022 Wind River Systems, Inc
# Copyright 2011 OpenStack Foundation
# Copyright 2011 - 2012, Red Hat, Inc.
#
@ -432,7 +431,7 @@ class Connection(object):
for iteration in itertools.count(0):
if limit and iteration >= limit:
raise StopIteration
return
yield self.ensure(_error_callback, _consume)
def cancel_consumer_thread(self):