Message164503
> 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(). |
|
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 | |
|