Skip to content

Commit

Permalink
Block both streams when loading files (jsk-ros-pkg#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Affonso-Gui committed Sep 7, 2022
1 parent c2c2e1a commit 1835664
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/euslime/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,14 @@ def swank_compile_file_if_needed(self, filename, loadp):
seconds, loadp, filename])

def swank_load_file(self, filename):
# Block both streams while loading a file (issue #10)
# Maybe there are other alternatives?
lock = self.euslisp.euslime_connection_lock
log.debug('Acquiring lock: %s' % lock)
lock.acquire()
internal_lock = self.euslisp.euslime_internal_connection_lock
log.debug('Acquiring lock: %s' % internal_lock)
internal_lock.acquire()
yield [Symbol(":write-string"), "Loading file: %s ...\n" % filename]
try:
cmd = '(slime::load-file-and-tags "{0}")'.format(qstr(filename))
Expand All @@ -566,9 +571,12 @@ def swank_load_file(self, filename):
yield [Symbol(":write-string"), "Loaded.\n"]
yield EuslispResult(res)
lock.release()
internal_lock.release()
except AbortEvaluation as e:
if lock.locked():
lock.release()
if internal_lock.locked():
internal_lock.release()
log.info('Aborting evaluation...')
# Force-print the message, which is
# by default only displayed on the minibuffer
Expand All @@ -580,6 +588,8 @@ def swank_load_file(self, filename):
except Exception:
if lock.locked():
lock.release()
if internal_lock.locked():
internal_lock.release()
raise

def swank_inspect_current_condition(self):
Expand Down

0 comments on commit 1835664

Please sign in to comment.