Executing a python script while it is running
castironpi at gmail.com
Wed Jun 17 12:34:47 EDT 2009
On Jun 16, 3:48 pm, Zach Hobesh <hob... at gmail.com> wrote:
> > A lot more information would be useful. What version of Python, and what
> > operating system environment? Exactly what would you like to happen when
> > the batch file is invoked a second time?
> I'm running Python 2.6.2 on Windows. I'm passing filenames to the
> batch files and I need all filenames to be processed. I can't have
> any fails. I'm working on logging any fails I do have so that I can
> maybe batch process at the end of the day.
> > 2) let them both run as separate processes
> This sounds like a good option, but I'm not totally sure on how to go
> about this?
> > 4) queue something to be processed when the first run finishes
> I had the same idea, but I believe it would involve having another
> python script run all day long, which wouldn't necessarily be a bad
> thing, but I'd like to explore other options as well.
This sort of falls under both categories, 2 & 4, and it will probably
be judged 'poor practice' by history. We're all historians now, I
Windows has what's called a 'named mutex' for interprocess
synchro'tion. Start your new process, acquire their shared mutex by
name, and block on it. You will have one process for each file, but
only one will run at once.
You won't even need to build a shared library; 'ctypes' will suffice.
More information about the Python-list