On Sunday 17 May 2009 21:54:54 Kent Johnson wrote: > On Sat, May 16, 2009 at 10:26 PM, Sylvain Ste-Marie > > <[email protected]> wrote: > > I'm currently writing a script to batch convert video for my psp > > > > It basically looks into a folder for video and launch ffmpeg: > > > > ffmpeg -i "videoname" -f psp -r 29.97 -b 768k -ar 24000 -ab 64k -s > > 368x208 "videoname.mp4" > > > > my idea is basically to check for pid but how do i do that? > > Look at psutil: > http://code.google.com/p/psutil/ > > But you will have a race condition if you do something like this: > > if ffmpeg is not running: > start ffmpeg > > A file lock is a better solution. Google 'python file lock' for recipes. >
As a Java programmer just starting with Python, this answer surprised me. I would've been googling for the Python equivalent of the Singleton pattern. I guess it's going to take longer than I thought to get my head around the differences. With the lock file solution, if your program crashes, don't you have to undertake some form of manual/automated recovery to remove any left over lock files? Regards _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
