Python Forum
schemes to stop my script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
schemes to stop my script
#1
i wrote a script to run ffmpeg to convert mp4 files to webm format to use less space on my my video disk and its two backups. webm uses vp9 which makes the files much smaller. but each file takes a long time to convert. it runs in a separate window like background and looks for more mp4 files when each gets done. this could run for many days. i have included a feature. if the file "/tmp/stop". i can create that file instead of hitting Ctrl-C to avoid killing ffmpeg. i am wondering if there is a better way to signal to a script that may be running some other program that is wanted to complete normally to end a big loop it is running.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
You could perhaps use a separate thread to communicate with the outside world.
Reply
#3
i do want to keep this change simple. testing the existence of a file is simpler. i'm thinking of changing it so it has the uid number and name of the program in it or as named by an option. i was wondering if anyone has created something that runs for a long time (hours or longer) in the background and might need to be gracefully stopped.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
Why not use unix signals?
Reply
#5
(Feb-18-2021, 06:21 AM)Gribouillis Wrote: Why not use unix signals?

that was my first thought. but i am unsure how to have a signal handler change a variable that gets used outside the handler. it still don't understand contexts in Python (and GIL) enough to be sure i can do this by signal. i could use SIGUSR1 for this. i do need to be sure different users won't effect each other, which a file in their home directory or a signal can easily do.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020