From 2e278ceb7450cc21182478366fef86a454ef4540 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 26 Jan 2023 15:26:43 -0500 Subject: [PATCH] Add a super hacky check for `xonsh`, smh.. --- tractor/_debug.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/tractor/_debug.py b/tractor/_debug.py index bfde43b..be0e8de 100644 --- a/tractor/_debug.py +++ b/tractor/_debug.py @@ -20,9 +20,13 @@ Multi-core debugging for da peeps! """ from __future__ import annotations import bdb +import os import sys import signal -from functools import partial +from functools import ( + partial, + cached_property, +) from contextlib import asynccontextmanager as acm from typing import ( Any, @@ -192,6 +196,22 @@ class MultiActorPdb(pdbpp.Pdb): def _cmdloop(self): self.cmdloop() + @cached_property + def shname(self) -> str: + ''' + Attempt to return the login shell name with a special check for + the infamous `xonsh` since it seems to have some issues much + different from std shells when it comes to flushing the prompt? + + ''' + # SUPER HACKY and only really works if `xonsh` is not used + # before spawning further sub-shells.. + xonsh_is_login_sh: bool = os.getenv('XONSH_LOGIN', default=False) + if xonsh_is_login_sh: + return 'xonsh' + + return os.path.basename(os.getenv('SHELL')) + @acm async def _acquire_debug_lock_from_root_task( @@ -691,17 +711,19 @@ def shield_sigint_handler( raise KeyboardInterrupt # NOTE: currently (at least on ``fancycompleter`` 0.9.2) - # it lookks to be that the last command that was run (eg. ll) + # it looks to be that the last command that was run (eg. ll) # will be repeated by default. # maybe redraw/print last REPL output to console since # we want to alert the user that more input is expect since # nothing has been done dur to ignoring sigint. if ( - pdb_obj + pdb_obj # only when this actor has a REPL engaged ): - # redraw the prompt ONLY in the actor that has the REPL running. - pdb_obj.stdout.write(pdb_obj.prompt) + # XXX: yah, mega hack, but how else do we catch this madness XD + if pdb_obj.shname == 'xonsh': + pdb_obj.stdout.write(pdb_obj.prompt) + pdb_obj.stdout.flush() # TODO: make this work like sticky mode where if there is output