Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
will_close bug (e.g. stash and recent betas)
-
@omz, In the latest beta, when running stash, if one switches to the console and types anything, all stash output gets sent to the console instead of the stash window. also, I am getting a lot more crashes when swicthing getween stash and console, for instance, starting a pip install, then tabbing over to the console causes a crash (works fine in pythonista2)
I realize stash is not your responsibility... but were there some fundamental changes with how the interpreter or console work in the last beta or two, that we need to ve working around? Any changes with how threads would work, for instance the thread state where sys.stdout is kept seems to be getting clobbered whenever typing in the console.
-
specifically: stash installes a custom sys.stdout which mimics StdOutCatcher. This seems to get overridden as soon as the console is touched, as if pythonista is recreating the StdOutCatcher every console line?
-
The monkey patch for
sys.stdout
is to allow running multiple commands of different output destinations without interfering each other. For an example, a HTTP server command can run at background with output redirected to a file, e.g.httpserver > logfile &
. At the same time, a foreground client can talk to the server and send output to stash screen or Pythonista console. This is achieved by the customstdout
object checking the caller thread and acting accordingly.I admit the whole monkey patch is not ideal and hacky. So if @omz could provide an official mechanism to allow plugins for
stdout
etc, it would be fantastic. -
@omz, @ywangd Ok, I found the issue.
Turns out will_close is now called onpanel
views whenever one switches from a view to the console.This appears to be a bug -- or cetainly not acting as documented, IMHO, will_close should be called when the view is closed, either from the close() method or user "x"ing the view. While it might be nice to have something like a
will_show
orwill_hide
to allow views to do someing when switching to or from a tab,will_close
seems like it should be reserved for actual closing of the view.As a temporary workaround, we should probably disable will_close in stash for beta versions 30012 and 30013 ( i forget where this started)
-
Thanks @JonB ! It was quite tricky to nail it down. I disabled the will_close call and it is now available in the
dev
branch. Hopefully this bug will be rectified soon. Thanks! -
I see, thanks! Should be fixed in the next beta.
-
@hyshai and @shaun-h Did the
sys.stdout
changes in the current betas also break the two youtube-dl implementations inPythonista-Tools
or is it just user error on my end?