← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1264054] Re: Optimize code, delete a try statement

 

This is not an equivalent change:  RuntimeError handler may also raise
exception which should be catched by Exception handler - after such
optimization it wouldn't.

** Changed in: neutron
       Status: In Progress => Invalid

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1264054

Title:
  Optimize code, delete a try statement

Status in OpenStack Neutron (virtual network service):
  Invalid

Bug description:
  The method serve_wsgi() in /neutron/neutron/service.py have two try statemens to capture exceptions,as follows:
  def serve_wsgi(cls):

      try:
          try:
              service = cls.create()
              service.start()
          except RuntimeError:
              LOG.exception(_('Error occurred: trying old api-paste.ini.'))
              service = cls.create('quantum')
              service.start()
      except Exception:
          LOG.exception(_('Unrecoverable error: please check log for details.'))
          raise

  it can be optimized and modified as:
  def serve_wsgi(cls):

      try:
          service = cls.create()
          service.start()
      except RuntimeError:
          LOG.exception(_('Error occurred: trying old api-paste.ini.'))
          service = cls.create('quantum')
          service.start()
      except Exception:
          LOG.exception(_('Unrecoverable error: please check log for details.'))
          raise

      return service

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1264054/+subscriptions


References