Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #15 from plone/datakurre-locks
Browse files Browse the repository at this point in the history
Replace object volatile attribute locks with global lock dictionary
  • Loading branch information
bloodbare committed Nov 17, 2016
2 parents b2693ea + 942bf3e commit 2ff77a1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/plone.server/plone/server/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
logger = logging.getLogger(__name__)


ASYNCIO_LOCKS = {}


class RequestAwareTransactionManager(transaction.TransactionManager):
"""Transaction manager for storing the managed transaction in the
Expand Down Expand Up @@ -303,10 +305,11 @@ def locked(obj):
"""
try:
assert obj._v_lock is not None
except (AssertionError, AttributeError):
obj._v_lock = asyncio.Lock()
return obj._v_lock
return ASYNCIO_LOCKS.get(obj._p_oid) or \
ASYNCIO_LOCKS.setdefault(obj._p_oid, asyncio.Lock())
except AttributeError: # obj has no _p_oid
return ASYNCIO_LOCKS.get(id(obj)) or \
ASYNCIO_LOCKS.setdefault(id(obj), asyncio.Lock())


def tm(request):
Expand Down

0 comments on commit 2ff77a1

Please sign in to comment.