#13826: Race condition in star_imports cache
--------------------------------+-------------------------------------------
Reporter: vbraun | Owner: GeorgSWeber
Type: defect | Status: needs_review
Priority: critical | Milestone: sage-5.5
Component: build | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Volker Braun | Merged in:
Dependencies: | Stopgaps:
--------------------------------+-------------------------------------------
Comment (by nbruin):
While we're nitpicking on possible race conditions anyway, isn't this
unsafe?
{{{
if star_imports is None:
cache_file = get_cache_file()
if os.path.exists(cache_file):
star_imports = pickle.load(open(cache_file))
else:
star_imports = {}
}}}
The file could get deleted between the existence check and the open.
Shouldn't one do
{{{
if star_imports is None:
cache_file = get_cache_file()
try:
opened_cache_file=open(cache_file)
except IOError, <whatever other errors should be caught>:
opened_cache_file=None
if opened_cache_file:
star_imports = pickle.load(opened_cache_file)
opened_cache_file.close()
else:
star_imports = {}
}}}
This is of course assuming that either the cachefile is valid or does not
exist. A "mv" on the filename shouldn't affect an already opened file.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13826#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.