Skip to content

Commit

Permalink
SQ -> Shell: Fix race condition where shell might start accepting com…
Browse files Browse the repository at this point in the history
…mands before foreground thread created
  • Loading branch information
davidfstr committed Jan 8, 2024
1 parent ea2c831 commit 9ed63e0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/crystal/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,16 @@ def _finish_launch(self, filepath: Optional[str]=None) -> None:
from crystal.util.xthreading import is_quitting, set_foreground_thread
set_foreground_thread(threading.current_thread())
try:
# (Don't insert anything between set_foreground_thread() and MyApp())
app = MyApp(redirect=False)

# Start shell if requested
if parsed_args.shell:
from crystal.shell import Shell
shell = Shell()
else:
shell = None

app = MyApp(redirect=False)

# Starts tests if requested
if parsed_args.test is not None:
from crystal.util.xthreading import bg_call_later, fg_call_later, has_foreground_thread
Expand Down

0 comments on commit 9ed63e0

Please sign in to comment.