Skip to content

Proper closing of MAD-X Instances #92

@JoschD

Description

@JoschD

Hey, I just stumbled upon this behaviour, that the madx instance still accepts commands even after it was closed.
Is this a known "bug"?

Code example:

from cpymad.madx import Madx
madx =  Madx()
madx.input("quit;")
madx.print(text="Still Printing")

with madx.exit() and madx.quit() everything is nicely ended (from the python side),
but a quit, exit, stop in the madx-code or madx.stop() only stops the madx run but still accepts commands.

This can be very annoying when quit is called within a file or macro, the cpymad run continues and runs fine (even reading and setting variables) , sporadically one can find messages like this in the output:

+++ memory access outside program range, fatal +++

but the program still continues to run until you do something fancy,
like a twiss, which fails then with a very non-distinct error message:

++++++ Error: seterrorflag : Errorcode: 1   Reported from pro_twiss:
++++++ Error: seterrorflag : Description: TWISS failed

Not sure if it would make sense to check in the output for:

++++++++++++++++++++++++++++++++++++++++++++
+          MAD-X finished normally         +
++++++++++++++++++++++++++++++++++++++++++++

I understand that this is probably not easy to fix, but maybe it should be included into the known issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions