SPF-OST / pytrnsys_gui

Graphical user interface for pytrnsys
https://pytrnsys.readthedocs.io
GNU Lesser General Public License v3.0
3 stars 4 forks source link

`IPython console`: server should run in-process but in a separate thread. #448

Open zuckerruebe opened 1 year ago

zuckerruebe commented 1 year ago

As a developer I want the server part of the IPython console to run

  1. in-process (with a view to being able to access the in-memory model the GUI is working on in the console later)
  2. in a separate thread so that the GUI is not blocked and can show log message which are printed to the console

The GUI should not allow the user to interact with it while a command is running on the server to ensure thread safety (the cleanest way to do this is probably showing a modal dialog to the user showing a message that a command is running).

N.B.: Currently log messages are not shown in the console because just before running a command the console replaces sys.stdin and friends with wrapper objects that forward the messages to the console. The loggers that we've previously configured elsewhere don't know about those wrapper objects, however, so we never write to them. The solution is, I think, to, just before running a command, setting up a logger that writes to the stdin wrapper and removing it right after the command was run.

zuckerruebe commented 1 year ago

Or, we say the server should run in a separate process which would have the advantage that we can safely not block the GUI while we run a simulation in the background... Maybe the "interact with the in-memory model of the system from the console" is pie in the sky anywya.