Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Python): CMCs release lock for unhandled runtime exceptions #979

Merged
merged 4 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ def __init__(self, wrapped):

def PutCacheEntry(self, input):
self.lock.Lock__()
val = self.wrapped.PutCacheEntry(input)
self.lock.Unlock()
try:
val = self.wrapped.PutCacheEntry(input)
finally:
self.lock.Unlock()
return val

def UpdateUsageMetadata(self, input):
self.lock.Lock__()
val = self.wrapped.UpdateUsageMetadata(input)
self.lock.Unlock()
try:
val = self.wrapped.UpdateUsageMetadata(input)
finally:
self.lock.Unlock()
return val

# NOT locked, as some sleeping might be involved
Expand All @@ -28,27 +32,35 @@ def GetCacheEntry(self, input):

def DeleteCacheEntry(self, input):
self.lock.Lock__()
val = self.wrapped.DeleteCacheEntry(input)
self.lock.Unlock()
try:
val = self.wrapped.DeleteCacheEntry(input)
finally:
self.lock.Unlock()
return val

def PutCacheEntry_k(self, input):
self.lock.Lock__()
val = self.wrapped.PutCacheEntry(input)
self.lock.Unlock()
try:
val = self.wrapped.PutCacheEntry(input)
finally:
self.lock.Unlock()
return val

def UpdateUsageMetadata_k(self, input):
self.lock.Lock__()
val = self.wrapped.UpdateUsageMetadata(input)
self.lock.Unlock()
try:
val = self.wrapped.UpdateUsageMetadata(input)
finally:
self.lock.Unlock()
return val

# This is the synchronization for GetCacheEntry and GetCacheEntry_k
def GetFromCacheInner(self, input):
self.lock.Lock__()
val = self.wrapped.GetFromCache(input)
self.lock.Unlock()
try:
val = self.wrapped.GetFromCache(input)
finally:
self.lock.Unlock()
return val

# NOT locked, because we sleep. Calls GetFromCache which IS synchronized.
Expand All @@ -73,8 +85,10 @@ def GetCacheEntry_k(self, input):

def DeleteCacheEntry_k(self, input):
self.lock.Lock__()
val = self.wrapped.DeleteCacheEntry(input)
self.lock.Unlock()
try:
val = self.wrapped.DeleteCacheEntry(input)
finally:
self.lock.Unlock()
return val

def __str__(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,56 +12,74 @@ def __init__(self, wrapped):

def PutCacheEntry(self, input):
self.lock.Lock__()
val = self.wrapped.PutCacheEntry(input)
self.lock.Unlock()
try:
val = self.wrapped.PutCacheEntry(input)
finally:
self.lock.Unlock()
return val

def UpdateUsageMetadata(self, input):
self.lock.Lock__()
val = self.wrapped.UpdateUsageMetadata(input)
self.lock.Unlock()
try:
val = self.wrapped.UpdateUsageMetadata(input)
finally:
self.lock.Unlock()
return val

def GetCacheEntry(self, input):
self.lock.Lock__()
val = self.wrapped.GetCacheEntry(input)
self.lock.Unlock()
try:
val = self.wrapped.GetCacheEntry(input)
finally:
self.lock.Unlock()
return val

def DeleteCacheEntry(self, input):
self.lock.Lock__()
val = self.wrapped.DeleteCacheEntry(input)
self.lock.Unlock()
try:
val = self.wrapped.DeleteCacheEntry(input)
finally:
self.lock.Unlock()
return val

def PutCacheEntry_k(self, input):
self.lock.Lock__()
val = self.wrapped.PutCacheEntry(input)
self.lock.Unlock()
try:
val = self.wrapped.PutCacheEntry(input)
finally:
self.lock.Unlock()
return val

def UpdateUsageMetadata_k(self, input):
self.lock.Lock__()
val = self.wrapped.UpdateUsageMetadata(input)
self.lock.Unlock()
try:
val = self.wrapped.UpdateUsageMetadata(input)
finally:
self.lock.Unlock()
return val

def GetFromCacheInner(self, input):
self.lock.Lock__()
val = self.wrapped.GetFromCache(input)
self.lock.Unlock()
try:
val = self.wrapped.GetFromCache(input)
finally:
self.lock.Unlock()
return val

def GetCacheEntry_k(self, input):
self.lock.Lock__()
val = self.wrapped.GetCacheEntry(input)
self.lock.Unlock()
try:
val = self.wrapped.GetCacheEntry(input)
finally:
self.lock.Unlock()
return val

def DeleteCacheEntry_k(self, input):
self.lock.Lock__()
val = self.wrapped.DeleteCacheEntry(input)
self.lock.Unlock()
try:
val = self.wrapped.DeleteCacheEntry(input)
finally:
self.lock.Unlock()
return val

def __str__(self):
Expand Down
Loading