diff options
author | Zuul <zuul@review.opendev.org> | 2020-05-22 22:11:37 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2020-05-22 22:11:37 +0000 |
commit | a075e5d365fb1acf66009d2c37fb9e0de9f174ee (patch) | |
tree | 78352f80afd71bfef3984f018b0f7e2090fcf649 | |
parent | 4c0480648d3b08fecbdadc126d9496fa3400f14e (diff) | |
parent | ee39ce31af7357d335e5e1f8d9eefa3e2f5fe76d (diff) | |
download | oslo-rootwrap-a075e5d365fb1acf66009d2c37fb9e0de9f174ee.tar.gz |
Merge "Avoid raising a RuntimeError during the shutdown"
-rw-r--r-- | oslo_rootwrap/client.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/oslo_rootwrap/client.py b/oslo_rootwrap/client.py index 0dd0742..a607be3 100644 --- a/oslo_rootwrap/client.py +++ b/oslo_rootwrap/client.py @@ -17,6 +17,7 @@ import logging from multiprocessing import managers from multiprocessing import util as mp_util import threading +import time import weakref import oslo_rootwrap @@ -41,6 +42,7 @@ except AttributeError: ClientManager = daemon.get_manager_class() LOG = logging.getLogger(__name__) +SHUTDOWN_RETRIES = 3 class Client(object): @@ -108,10 +110,14 @@ class Client(object): if process.poll() is None: LOG.info('Stopping rootwrap daemon process with pid=%s', process.pid) - try: - manager.rootwrap().shutdown() - except (EOFError, IOError): - pass # assume it is dead already + for _ in range(SHUTDOWN_RETRIES): + try: + manager.rootwrap().shutdown() + break + except (EOFError, IOError): + break # assume it is dead already + except RuntimeError: + time.sleep(0.2) # We might want to wait for process to exit or kill it, but we # can't provide sane timeout on 2.x and we most likely don't have # permisions to do so |