#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):
OK, code is probably less ambiguous than trying to explain in words. Why
do you do
{{{
+ try:
+ os.unlink(cache_file)
+ except OSError:
+ pass # cache_file does not exist, fine
+ # important: create temp dir in cache_dir (trac #13826) to move
atomically
+ _, tmp_file = tempfile.mkstemp(dir=cache_dir)
+ with open(tmp_file, "w") as tmp:
+ pickle.dump(star_imports, tmp)
+ try:
+ os.rename(tmp_file, cache_file)
+ except OSError:
+ pass # Windows can end up here, ignore
}}}
instead of
{{{
+ # important: create temp dir in cache_dir (trac #13826) to move
atomically
+ _, tmp_file = tempfile.mkstemp(dir=cache_dir)
+ with open(tmp_file, "w") as tmp:
+ pickle.dump(star_imports, tmp)
+ try:
+ os.unlink(cache_file)
+ except OSError:
+ pass # cache_file does not exist, fine
+ try:
+ os.rename(tmp_file, cache_file)
+ except OSError:
+ remove tmp_file if rename failed.
}}}
Replying to [comment:12 vbraun]:
> `sage -b` deletes the lazy import cache already. Are you saying that it
doesn't work on your system?
Ah, ok, it does. That alleviates the problem to some degree. I haven't
been able to locate the code that does it, but it will only delete the
cache in the `.sage/cache` of the UID running `sage -b`. So other UIDs are
still out of luck. It seems to me that if `sage -b` knows when the cache
needs to be refreshed then it should do so and the cache should probably
be somewhere in sage_root rather than in a user directory.
Perhaps rationalizing where the cache is held is something for a follow-up
ticket.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13826#comment:15>
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.