Merge pull request #9 from LeetCode-OpenSource/fix_memory_leaks

Fix memory leaks in LspEndpoint
This commit is contained in:
Yeger 2019-12-08 09:05:53 +02:00 committed by GitHub
commit b6d7378121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,11 +88,14 @@ class LspEndpoint(threading.Thread):
self.next_id += 1 self.next_id += 1
cond = threading.Condition() cond = threading.Condition()
self.event_dict[current_id] = cond self.event_dict[current_id] = cond
cond.acquire() cond.acquire()
self.send_message(method_name, kwargs, current_id) self.send_message(method_name, kwargs, current_id)
cond.wait() cond.wait()
cond.release() cond.release()
result, error = self.response_dict[current_id]
self.event_dict.pop(current_id)
result, error = self.response_dict.pop(current_id)
if error: if error:
raise lsp_structs.ResponseError(error.get("code"), error.get("message"), error.get("data")) raise lsp_structs.ResponseError(error.get("code"), error.get("message"), error.get("data"))
return result return result