开云体育

Closing or Teminating Scripts #scripting


 

In my quest of developing scripts, I often test, re-write, save (under a new name), re-run and continue.
?
After hearing an old script still running.... and I checked the theads; nothing is runing, or so I thought.
?
So without rebooting JMRI, hoe wo a check, and close active scrpts running in the back ground?
?
Be patient with me, this old bird is learning fast.
?
Darrin Calcutt
Canadian Locomotive Logistics
?


 

Darrin,

Did you download and look at the Demo.py script that I uploaded?

There are two kinds of persistence in Jython scripts.

"AbstractAutomaton" scripts create separate threads which are visible using the "Thread Monitor". ?It provides the ability to "stop" a thread.

Scripts using "PropertyChangeListener" attach a listener to JMRI objects, such as turnouts, sensors, etc. ?The listeners are created by a script but a listener is independent after the script has finished. ? The Demo.py script shows how to "remove" a listener from a JMRI object.

If you look at the actual execution of a Jython script, they run quickly. ?The Demo.py script runs in 12ms. ?However, it leaves behind an?AbstractAutomaton class definition and a sensor listener, along with any changes to global Jython variables.

Dave Sand



----- Original message -----
From: "Canadian Locomotive Logistics via groups.io" <CanadianLocomotiveLogistics=[email protected]>
Subject: [jmriusers] Closing or Teminating Scripts
Date: Wednesday, March 26, 2025 11:10 AM

In my quest of developing scripts, I often test, re-write, save (under a new name), re-run and continue.
?
After hearing an old script still running.... and I checked the theads; nothing is runing, or so I thought.
?
So without rebooting JMRI, hoe wo a check, and close active scrpts running in the back ground?
?
Be patient with me, this old bird is learning fast.
?
Darrin Calcutt
Canadian Locomotive Logistics
?


 

I started tooo last night.... THan k you.