From: Liu, J. (C-BASS) <Jes...@c-...> - 2001-08-10 18:13:40
|
Thanks for the reply. Late is always better than never.:) I looked up in the source code a little bit and found the following in CachedJarsPackageManager.java: /** Open cache index for writing back to persistent storage - hook. * This default impl is part of the off-the-shelf local * file-system cache impl. * Can be overriden. */ protected DataOutputStream outOpenIndex() throws IOException { File indexFile = new File(cachedir, "packages.idx"); return new DataOutputStream( new BufferedOutputStream(new FileOutputStream(indexFile))); } Since there is no file locking here(is there any one in Java, BTW?), if 2 processes are writing to the same "packages.idx", you may get garbage. If this garbage isn't in the format the PackageManager can recognize, the cache will simply be ignored and the jars are processed again. However, what if the garbage happens to make sense but points to different location of the jar? I guess the behavior is simply unpredictable. Also the chance of this happening shall be really small that we can pretend it never happen(what's the chance all oxygen molecules move to the other side of the room at the same time s.t. you will be suffocated anyway?) So separate cache dir seems reliable for a critical task, but if I need a cache for each user, each host and each process, why do I need it at all? I wish I have the freedom to specify when to update a cache, then I will just need to create the cache once for the first time and never update it unless it is instructed. -----Original Message----- From: Samuele Pedroni [mailto:pe...@in...] Sent: Friday, August 10, 2001 10:15 AM To: jyt...@li...; Liu, Jesse (C-BASS) Subject: Re: [Jython-users] Q: Package Manager in jpython/jython Sorry for answering only now > > I am running multiple processes using jython2.0 in NFS. These processes may > have different python paths but use the same cache dir and access the same > files there. Is there any danger these processes will clobber each other and > produce unpredictable results, i.e. using a wrong package? What exactly > would a Package Manager do in this case? Thanks. > > Jesse Liu > I would say, that it is better to use separate cache dir if your process access new jars sometime, there is no concurrency control for cache accesses, OTOH if the set of accessed jar is someone fixed then the cache (once setup) is used just in read-only mode and there should be no problem. regards, Samuele Pedroni. |