multiprocessing & more
andrea.crotti.0 at gmail.com
Mon Feb 14 11:33:21 CET 2011
On Feb 14, 12:14 am, Adam Skutt <ask... at gmail.com> wrote:
> On Feb 13, 12:34 pm, Andrea Crotti <andrea.crott... at gmail.com> wrote:
> > First of all, does it make sense to use multiprocessing and a short
> > value as boolean to check if the simulation is over or not?
> Maybe, but without knowing exactly what you're doing it's difficult to
> say if any other approach would be superior. Plus, most of the other
> approaches I can think of would require code modifications or platform-
> specific assumptions.
Well the other possibility that I had in mind was to spawn the very
long process in an asynchronous way, but then I still have the
problem to notify the rest of the program that the simulation is over.
Is there a way to have an asynchronous program that also notifies when
it's over easily?
Otherwise I'll leave it like this it works apparently well...
The only thing is that debugging (with pdb) is not so trivial, but
for that I can use unit tests and check on older simulation results.
> File I/O is inherently a concurrent, unsynchronized activity. A
> directory listing can become stale at any time, even while the
> directory listing is being built (e.g., imagine running ls or dir in a
> directory where rm or del is currently executing). When a directory
> is being modified while you're listing it, the contents of the listing
> essentially become "undefined": you may get entries for files that no
> longer exist, and you may not get entries for that do exist. A
> directory listing may also return duplicate entries; this is what I
> expect is happening to you.
> The right thing to do is actually check to see if all the files you
> want exist, if you can. If not, you'll have to keep waiting until
> you've opened all the files you expect to open.
Yes that would be a solution, but I can't know in the python program
what file names there will be in the directory, I can only know
how many will be there.
So I think the easy and stupid solution is just to wait a couple of
and everyone is happy ;)
More information about the Python-list