#10004: The gap instances in a parallelised function do not always have distinct
_local_tmpfile
--------------------------+-------------------------------------------------
   Reporter:  SimonKing   |       Owner:  was                     
       Type:  defect      |      Status:  needs_review            
   Priority:  blocker     |   Milestone:  sage-4.6.1              
  Component:  interfaces  |    Keywords:  _local_tmpfile, parallel
     Author:  Simon King  |    Upstream:  N/A                     
   Reviewer:              |      Merged:                          
Work_issues:              |  
--------------------------+-------------------------------------------------
Changes (by newvalueoldvalue):

  * status:  new => needs_review
  * author:  => Simon King


Comment:

 Now it seems to work! With the patch, I get

 1. Caching works
 {{{
   sage: gap._local_tmpfile() is gap._local_tmpfile()
   True
 }}}

 2. Different interfaces have different tmpfiles:
 {{{
   sage: gap._local_tmpfile() != singular._local_tmpfile()
   True
 }}}

 3. Parallelisation works:
 {{{
   sage: @parallel
   ....: def f(n):
   ....:     return gap._local_tmpfile()
   ....:
   sage: L = [t[1] for t in f(range(5))]
   sage: len(set(L))
   5
   sage: print gap._local_tmpfile()
   /home/king/.sage//temp/gauss/24281//interface//tmp24283
   sage: L = [t[1] for t in f(range(5))]
   sage: len(set(L))
   5
 }}}

 The ideas for my patch are:

 1. As before, the name of the file is cached in an attribute
 !__local_tmpfile.

 2. If !__local_tmpfile is not there or is None, then a new filename is
 created, which depends on pid(). This is different for different interface
 instances, including different forks of a parallelised function.

 3. It must be ensured that the cache is emptied before forking. This is
 implemented in {{{Expect.quit()}}}: !__local_tmpfile is set to None (I
 tested that !__delattr!__ did not do the job).

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10004#comment:4>
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.

Reply via email to