Skip to content

Commit

Permalink
fix race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
d-maurer committed Jul 23, 2019
1 parent 412d94b commit 9663dfc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
4.4 (unreleased)
================

- Nothing changed yet.
- Avoid race condition in ``deferredmodule.ModuleProxy.__getattr__``
`#8 <https://github.com/zopefoundation/zope.deferredimport/issues/8>`_.


4.3 (2018-10-05)
Expand Down
6 changes: 5 additions & 1 deletion src/zope/deferredimport/deferredmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,15 @@ def __init__(self, module):

def __getattr__(self, name):
try:
get = self.__deferred_definitions__.pop(name)
get = self.__deferred_definitions__[name]
except KeyError:
raise AttributeError(name)
v = get.get()
setattr(self, name, v)
try:
del self.__deferred_definitions__[name]
except KeyError:
pass
return v

def initialize(level=1):
Expand Down

0 comments on commit 9663dfc

Please sign in to comment.