Hi Terry,

> Immediately after successfully terminating, the MP3 Player restarts
> and I can't see why.

Whatever starts it the first time is running again.

> python3 -m trace --count -C . minstermusic.py
>
> Unfortunately, I get no output from the trace command because the program is
> designed to never finish

And because you chose an annotated listing with a count of the number of
times each line was run which is only known at the end of the program.
It also isn't what you want, as you say below.  You want a trace and
that shows up as the program is running.

    $ cat terry.py
    #! /usr/bin/python

    def mul(a, b): return a * b

    for n in range(3):
        print(n, mul(6, 7))
    $
    $ ./terry.py
    0 42
    1 42
    2 42
    $
    $ python -m trace -t terry.py
     --- modulename: terry, funcname: <module>
    terry.py(3): def mul(a, b): return a * b
    terry.py(5): for n in range(3):
    terry.py(6):     print(n, mul(6, 7))
     --- modulename: terry, funcname: mul
    terry.py(3): def mul(a, b): return a * b
    0 42
    terry.py(5): for n in range(3):
    terry.py(6):     print(n, mul(6, 7))
     --- modulename: terry, funcname: mul
    terry.py(3): def mul(a, b): return a * b
    1 42
    terry.py(5): for n in range(3):
    terry.py(6):     print(n, mul(6, 7))
     --- modulename: terry, funcname: mul
    terry.py(3): def mul(a, b): return a * b
    2 42
    terry.py(5): for n in range(3):
    $

> Is there a way in Python to leave the running software cleanly by
> simply executing a Python statement?

    $ python -c 'raise SystemExit; print(42)'
    $ echo $?
    0
    $ python -c 'raise SystemExit(1); print(42)'
    $ echo $?
    1

There's also sys.exit().  See
https://docs.python.org/3/library/exceptions.html#SystemExit

-- 
Cheers, Ralph.

-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-03-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk

Reply via email to