On 31 October 2017 at 02:06, Paul Moore <p.f.moore@gmail.com> wrote:
On 30 October 2017 at 15:53, Antoine Pitrou <solipsis@pitrou.net> wrote:
> On Tue, 31 Oct 2017 01:44:10 +1000
> Nick Coghlan <ncoghlan@gmail.com> wrote:
>> (We'd want a real process restart, rather than emulating it by calling
>> Py_Initialize & Py_Finalize multiple times, as not every module properly
>> supports multiple initialise/finalise cycles within a single process, and
>> module-specific quirks are exactly what we'd be trying to avoid by forcing
>> an interpreter restart)
>
> The main difference, though, is that a notebook will reload and
> replay all your session, while restarting the regular REPL will simply
> lose all current work.  I think that makes the idea much less
> appealing.

Right, but if you want an installation to work reliably, you're going to lose that state anyway. Erik's original comment included the suggestion to "give them an opportunity to cancel the
action in case they have any work they need to save", and I think some kind of warning's going to be necessary no matter how we handle the restart.
 
Also, on Windows, I believe that any emulation of execve either leaves
the original process in memory, or has problems getting console
inheritance right. It's been a long time since I worked at that level,
and things may be better now, but getting a robust "restart this
process" interface in Windows would need some care (that's one of the
reasons the py launcher runs Python as a subprocess rather than doing
any sort of exec equivalent).

As long as the standard streams are passed along correctly, whatever the py launcher does would presumably be adequate for a REPL restart as well, assuming we decided to go down that path.

It would also be reasonable to say that the regular REPL just issues a warning that a restart might be needed, and it's only REPLs with a separate client process that offer a way to restart the subprocess where code actually executes.

Cheers,
Nick.

--
Nick Coghlan   |   ncoghlan@gmail.com   |   Brisbane, Australia