Published on InterSystems Developer Community (https://community.intersystems.com)

Home > Stopping IRIS processes caching Python code

Question
Adrian Maguire · Sep 16, 2022

Stopping IRIS processes caching Python code

We're having a problem with the way Python modules are being cached in Iris. If we modify some code and then reimport a module it is still processing the old code.

E.g. Create a python file:

helloWorld.py

def helloWorld() :
  return "Hello world"

The run the following in the Iris terminal:

SOURCENEW>set helloWorld = ##class(%SYS.Python).Import("helloWorld")
 
SOURCENEW>w helloWorld.helloWorld()
Hello world

Modify helloWorld.py

def helloWorld() :
  return "Hello world again"

In the same terminal process run the commands again, the same result is even though the code has been changed.

SOURCENEW>kill helloWorld
 
SOURCENEW>set helloWorld = ##class(%SYS.Python).Import("helloWorld")
 
SOURCENEW>w helloWorld.helloWorld()
Hello world

Only when I start a new process is the new code used.

Is there a way we can we stop the code from being cached without killing all the processes that have loaded it?

#Embedded Python #Python #InterSystems IRIS
Product version: IRIS 2022.1
$ZV: IRIS for Windows (x86-64) 2022.1 (Build 209U) Tue May 31 2022 12:16:40 EDT

Source URL:https://community.intersystems.com/post/stopping-iris-processes-caching-python-code