Skip to content

Commit

Permalink
Acquire lock when using Jedi.
Browse files Browse the repository at this point in the history
This should ensure thread safety, but might not give the best
performance. It might be possible to skip processing of some
requests if too many arrive in a short interval instead of processing
all of them with a delay once the lock becomes available for each
request.

Addresses #975.
  • Loading branch information
jgosmann authored and tcstewar committed Jun 21, 2018
1 parent 86f34a6 commit fabd3c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Release History
0.4.3 (unreleased)
==================

- Bugfix: thread-safety for jedi autocompletion
- Bugfix: Handle authentication when connecting to multiple servers
- Bugfix: Fail gracefully when binding server

Expand Down
8 changes: 6 additions & 2 deletions nengo_gui/completion.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import threading
import warnings

try:
Expand All @@ -14,6 +15,9 @@ def completions(self):
return []


_jedi_lock = threading.Lock()

def get_completions(code, line, column, path=None):
script = Script(code, line, column, path=path)
return script.completions()
with _jedi_lock:
script = Script(code, line, column, path=path)
return script.completions()

0 comments on commit fabd3c8

Please sign in to comment.