Skip to content

Commit

Permalink
Trying to make long prints interruptable
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesShaker committed Nov 22, 2018
1 parent 1ec856a commit 0d9f59e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions repls/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self, encoding, external_id=None, cmd_postfix="\n", suppress_echo=F
self.suppress_echo = suppress_echo
self.additional_scopes = additional_scopes or []
self.apiv2 = apiv2
self.store_dict = {}

def autocomplete_available(self):
return False
Expand Down Expand Up @@ -99,3 +100,5 @@ def read(self):
self.reset_decoder()
if output:
return output
def set_ref(self,ref_string,ref_obj):
self.store_dict[ref_string] = ref_obj
4 changes: 4 additions & 0 deletions repls/sublimehol_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def write(self, command):
def send_signal(self, sig):
if sig == signal.SIGTERM:
self._killed = True
out_queue = self.store_dict.get("print_queue",None)
elif sig == signal.SIGINT and out_queue:
with out_queue.mutex:
out_queue.queue.clear()
if self.is_alive():
#Need to send signal to children because HOL runs everything
#in build heap
Expand Down
1 change: 1 addition & 0 deletions sublimehol.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def __init__(self, view, repl, syntax, repl_restart_args):

#create writer queue and thread
self._work_queue = queue.Queue()
self.repl.set_ref("print_queue",self._work_queue)
self._worker = threading.Thread(target=self._write_worker)
self._worker.start()

Expand Down

0 comments on commit 0d9f59e

Please sign in to comment.