callback can't unsubscribe itself in python3

Bug #1592983 reported by Kevin Benton
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Low
Kevin Benton

Bug Description

The callback manager uses .items() which is not a copy of the subscribers dict in python3. This means that a callback that wants to unsubscribe itself will die in python3 with an error:

   b' self.manager.notify(resources.PORT, events.BEFORE_CREATE, mock.ANY)'
    b' File "/home/administrator/code/neutron/neutron/callbacks/manager.py", line 118, in notify'
    b' errors = self._notify_loop(resource, event, trigger, **kwargs)'
    b' File "/home/administrator/code/neutron/neutron/callbacks/manager.py", line 143, in _notify_loop'
    b' for callback_id, callback in callbacks:'
    b'RuntimeError: dictionary changed size during iteration'
    b''

Changed in neutron:
assignee: nobody → Kevin Benton (kevinbenton)
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.openstack.org/330209

Changed in neutron:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/330209
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=2fbb6587df357583fe03b8616d7b95f79382af20
Submitter: Jenkins
Branch: master

commit 2fbb6587df357583fe03b8616d7b95f79382af20
Author: Kevin Benton <email address hidden>
Date: Sat Jun 11 08:23:48 2016 -0700

    Allow self-unsubscribing callbacks

    This adjusts the notify loop logic to handle the case where
    a callback causes a subscription or unsubscription that changes
    the subscriber dictionary to change during iteration.

    It was just using .items() which solved the problem for py27 but
    was not creating an actual copy in py34. This just calls list()
    on .items() to make sure we get a list in both cases.

    Change-Id: Iee9d675faf30ec714b4f5c77128d8843d545ecfd
    Closes-Bug: #1592983

Changed in neutron:
status: In Progress → Fix Released
tags: added: neutron-proactive-backport-potential
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/neutron 9.0.0.0b2

This issue was fixed in the openstack/neutron 9.0.0.0b2 development milestone.

tags: removed: neutron-proactive-backport-potential
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.