glance-manage db_load_metadefs should use 'with open as...'

Bug #1367172 reported by Pawel Koniszewski
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Low
Pawel Koniszewski

Bug Description

Currently script which loads metadeta definitions to database uses try except block with open(file) inside. There is better solution in Python for file streams - use 'with open(file) as...'. With this approach we will be sure that every resource is cleaned up when the code finishes running.

Tags: metadef
Changed in glance:
status: New → In Progress
assignee: nobody → Pawel Koniszewski (pawel-koniszewski)
Revision history for this message
Pawel Koniszewski (pawel-koniszewski) wrote :

Review: https://review.openstack.org/#/c/120041/
No idea why it wasn't linked.

tags: added: metadef
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

Reviewed: https://review.openstack.org/120041
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=2df48336d0e0381522e9ec100cb56579367cfa1f
Submitter: Jenkins
Branch: master

commit 2df48336d0e0381522e9ec100cb56579367cfa1f
Author: Pawel Koniszewski <email address hidden>
Date: Wed Sep 10 05:06:03 2014 -0400

    Change open(file) to with block

    Currently script which loads metadata definitions to database
    uses open(file) to stream files. This isn't the best practice
    because in case of any errors this code may not be safe.
    To solve this problem this patch changes open(file) to
    'with open(file) as...:' block. It allows us to ensure that every
    resource is cleaned up when the code finishes running.

    Change-Id: I4a85700061ed5050f4356f1b39ea128931626c83
    Closes-Bug: #1367172

Changed in glance:
status: In Progress → Fix Committed
Dolph Mathews (dolph)
Changed in glance:
milestone: none → juno-rc1
Dolph Mathews (dolph)
Changed in glance:
importance: Undecided → Low
Thierry Carrez (ttx)
Changed in glance:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in glance:
milestone: juno-rc1 → 2014.2
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.