Iterating over a WeakKeyDictionary isn't thread-safe
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
wsgi-oops |
Fix Committed
|
Undecided
|
Anthony Lenton |
Bug Description
Working with the latest wsgi-oops, we sometimes get the following
Traceback (most recent call last):
File "/srv/login.
return oops(environ, start_response)
File "/usr/lib/
response_
File "/usr/lib/
environ[
File "/usr/lib/
self.id = self._oops_
File "/usr/lib/
day, sequence = self.get_
File "/usr/lib/
serializer in self._serialize
File "/usr/lib/
sequence = max(serializer.
File "/usr/lib/
for wr in self.data.
RuntimeError: dictionary changed size during iteration
You usually see this error pop up a couple of times during load tests.
Related branches
- Elliot Murphy (community): Approve
-
Diff: 13 lines (+2/-1)1 file modifiedcanonical/oops/serializer.py (+2/-1)
summary: |
- wsgi-oops still isn't thread-safe + Iterating over a WeakKeyDictionary isn't thread-safe |
description: | updated |
Changed in wsgi-oops: | |
status: | New → In Progress |
assignee: | nobody → Anthony Lenton (elachuni) |
Changed in wsgi-oops: | |
status: | In Progress → Fix Committed |
tags: | added: canonical-losa-isd |
Apparently iterators obtained from WeakKeyDictionaries aren't threadsafe, since finalization may modify the underlying dict at any time. For now, we can avoid using iterators obtained from WeakKeyDictiona ries, but this is arguably a bug in WeakKeyDictionary.