This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients kaniini, rhettinger, serhiy.storchaka, xiang.zhang
Date 2016-06-10.17:31:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1465579919.74.0.716884348595.issue27275@psf.upfronthosting.co.za>
In-reply-to
Content
I'm wondering if the expiringdict(1) needs to have locked wrappers for the inherited methods:

    def __delitem__(self, key):
        with self.lock:
            OrderedDict.__delitem__(self, key)

Otherwise, there is a risk that one thread is deleting a key with no lock held, while another thread is running expiringdict.popitem() which holds a lock while calling both __getitem__ and del.  If the first thread runs between the two steps in the second, the race condition would cause a KeyError.

This might explain why you've observed, '''Replacing use of popitem() with "del self[next(OrderedDict.__iter__(self))]" removes the KeyErrors and the structure otherwise works fine.'''

(1) https://github.com/mailgun/expiringdict/blob/master/expiringdict/__init__.py
History
Date User Action Args
2016-06-10 17:31:59rhettingersetrecipients: + rhettinger, serhiy.storchaka, xiang.zhang, kaniini
2016-06-10 17:31:59rhettingersetmessageid: <1465579919.74.0.716884348595.issue27275@psf.upfronthosting.co.za>
2016-06-10 17:31:59rhettingerlinkissue27275 messages
2016-06-10 17:31:59rhettingercreate