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

Add a lock to protect the coordinator to avoid data race condtions. #1445

Merged
merged 3 commits into from
Apr 8, 2022
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
2 changes: 2 additions & 0 deletions analytical_engine/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.cache/

10 changes: 9 additions & 1 deletion python/graphscope/client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,9 @@ def __init__(
# networkx module
self._nx = None

# a lock that protects the coordinator
self._lock = threading.Lock()

def __repr__(self):
return str(self.info)

Expand Down Expand Up @@ -937,7 +940,7 @@ def _wrapper(self, dag_node):
return dag_node

def run(self, fetches, debug=False):
"""Run operations of `fetch`.
"""Run operations of `fetches`.
Args:
fetch: :class:`Operation`

Expand All @@ -955,6 +958,11 @@ def run(self, fetches, debug=False):
Returns:
Different values for different output types of :class:`Operation`
"""
with self._lock:
return self.run_fetches(fetches, debug)

def run_fetches(self, fetches, debug=False):
"""Run operations of `fetches` without the session lock."""
if self._closed:
raise RuntimeError("Attempted to use a closed Session.")
if not self._grpc_client:
Expand Down