Paraview's Python "Reset" button doesn't actually reset


I’m seeing weird issues with the “Reset” button of Paraview’s python shell. I thought (as it resets the shell) that it would also reset the global environment. That doesn’t appear to be the case:

Here’s how to reproduce it: make two files

import sys, os

from b import g
g = 1


Only workaround is to close Paraview entirely then run

What does the Reset button exactly?

Thanks a lot for the support

— Setup

  • Client:
    • Paraview: 5.9.1-1209
    • Debian GNU/Linux 11 (bullseye)

Technically, this button only calls:
from paraview.simple import *

It does not reinitiazs the python intepreter or reset ParaView.

Not sure what you are trying to achieve though.

I thought the Reset button would reset the python interpreter… Typically in most IDEs reseting Python means deleting all globals/locals (e.g. that what IDLE does…). Isn’t that what it’s made for?

From my understanding it calls vtkPythonInterpreter::Initialize through

But vtkPythonInterpreter::Initialize does almost nothing when the Python interpreter is already initialized.

Your analysis is correct. Should this be changed ? maybe, but this is not the same question.

wdyt @utkarsh.ayachit ?

There’s no resetting the Python interpreter. AFAIK, Python doesn’t support calling Finalize and then Initialize again. Reset only resets the interactive interpreter created for the shell…thus any globals will persist.

1 Like

AFAIK, Python doesn’t support calling Finalize and then Initialize again.

I’m pretty sure this is incorrect. It seems to be supported when you read Initialization, Finalization, and Threads — Python 3.9.6 documentation

I tried it out and it works apparently just fine. Globals are properly dismissed.

I made a PR over Feel free to have a look (have I missed something obvious ? :sweat_smile:)