Skip to content

Commit

Permalink
Merge pull request #118 from mit-submit/main
Browse files Browse the repository at this point in the history
add logging on lock release(s)
  • Loading branch information
mdr223 authored Oct 21, 2023
2 parents 7c6811c + e220643 commit 5053f3a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions A2rchi/interfaces/chat_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def __call__(self, history: Optional[List[Tuple[str, str]]], discussion_id: Opti
Execute the chat functionality.
"""
self.lock.acquire()
print("INFO - acquired lock file")
try:
# convert the history to native A2rchi form (because javascript does not have tuples)
history = self.convert_to_chain_history(history)
Expand Down Expand Up @@ -152,6 +153,7 @@ def __call__(self, history: Optional[List[Tuple[str, str]]], discussion_id: Opti
raise e
finally:
self.lock.release()
print("INFO - released lock file")
return output, discussion_id


Expand Down Expand Up @@ -220,6 +222,7 @@ def terms(self):

def like(self):
self.chat.lock.acquire()
print("INFO - acquired lock file")
try:
# Get the JSON data from the request body
data = request.json
Expand All @@ -246,9 +249,11 @@ def like(self):
# this will still execute, before the function returns in the try or except block.
finally:
self.chat.lock.release()
print("INFO - released lock file")

def dislike(self):
self.chat.lock.acquire()
print("INFO - acquired lock file")
try:
# Get the JSON data from the request body
data = request.json
Expand Down Expand Up @@ -283,3 +288,4 @@ def dislike(self):
# this will still execute, before the function returns in the try or except block.
finally:
self.chat.lock.release()
print("INFO - released lock file")

0 comments on commit 5053f3a

Please sign in to comment.