Message164503
| Author |
sbt |
| Recipients |
brian.curtin, dabrahams, davide.rizzo, dlenski, eric.araujo, eric.smith, jaraco, ncoghlan, pitrou, r.david.murray, sbt, tim.golden |
| Date |
2012年07月01日.22:46:14 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1341182775.55.0.361093237736.issue14243@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
> Agreed. Richard: do you have time to put something together?
> I'm happy to try if you don't.
I'm looking into it.
Unfortunately, it seems that you need to use non-default flags when reopening a shared file. Eg, if the file is currently opened with SH_DENYNO and O_TEMPORARY, then you must reopen it using SH_DENYNO and O_TEMPORARY.
However, I have an initial implementation of os.sopen() which makes the following work:
import os, tempfile
FNAME = "foo.txt"
DATA = "hello bob"
def opener(name, flag, mode=0o777):
return os.sopen(name, flag | os.O_TEMPORARY, os.SH_DENYNO, mode)
with open(FNAME, "w", opener=opener) as f:
f.write(DATA)
f.flush()
with open(FNAME, "r", opener=opener) as f:
assert f.read() == DATA
assert not os.path.exists(FNAME)
BTW, Maybe it would be better to add a keyword-only shareflag argument to os.open() rather than add os.sopen(). |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年07月01日 22:46:15 | sbt | set | recipients:
+ sbt, jaraco, ncoghlan, pitrou, eric.smith, tim.golden, eric.araujo, r.david.murray, brian.curtin, dabrahams, davide.rizzo, dlenski |
| 2012年07月01日 22:46:15 | sbt | set | messageid: <1341182775.55.0.361093237736.issue14243@psf.upfronthosting.co.za> |
| 2012年07月01日 22:46:14 | sbt | link | issue14243 messages |
| 2012年07月01日 22:46:14 | sbt | create |
|