Uploaded image for project: 'Red Hat OpenStack Services on OpenShift'
  1. Red Hat OpenStack Services on OpenShift
  2. OSPRH-21757

Simplify process group fallback logic in amqpdriver.py.

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Normal Normal
    • None
    • None
    • Oslo
    • None
    • Sprint 9
    • 1

      The current implementation in amqpdriver.py uses an explicit conditional to handle a rare edge case where os.getpgrp() may return 0 (for example when running under the crun container runtime):

      proc_id = self.pg if self.pg != 0 else os.getpid()

      This patch simplifies the expression by using the more idiomatic Python fallback pattern:

      proc_id = self.pg or os.getpid()

      Using or preserves the same behavior, correctly handling any falsy values (0, None, etc.), while making the code shorter and more readable.
      This change does not alter behavior — it’s purely a readability improvement on top of the previous fix for the crun runtime case.

      Rationale

      Keeps the same behavior for pg=0 and pg=None

      More Pythonic and concise

      Improves code readability and maintainability

      Impact

      None on functionality.
      The change only affects readability and expression style.

      References

      Gerrit change: https://review.opendev.org/c/openstack/oslo.messaging/+/965938

              mbollo@redhat.com Daniel Mats Niklas Bengtsson
              mbollo@redhat.com Daniel Mats Niklas Bengtsson
              rhos-dfg-pidone
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: