May be it is Python's multiprocessing then?.  The script does a LOOP 
calling integrate command.

But it does each call in separate process, using Python's MP. 

Each command seems to create few folders. I just did one command
and saw  these created:

rwx------  2 me me            4096 Aug 15 09:53 tmpmyvujuyg
drwx------  2 me me            4096 Aug 15 09:53 tmpd14tubax
drwx------  2 me me            4096 Aug 15 09:53 tmpmp7uvinu
drwx------  2 me me            4096 Aug 15 09:53 tmpe7tycr65
drwx------  2 me me            4096 Aug 15 09:53 tmpg0mt3zb4

Since the script runs for 10's of thousands of integrals, and I have 3 
running at same time, my TMP
fills up and Linux runs short of file nodes and get warning that desk space 
is short (even though
the folder are empty, it is the file nodes causing this).  See

this-computer-has-only-0-bytes-disk-remaining-message-from-linux-running-on-vi 
<https://unix.stackexchange.com/questions/741127/this-computer-has-only-0-bytes-disk-remaining-message-from-linux-running-on-vi>

I use multiprocessing, since that is only way I know to  set a timeout on 
the
integrate command, since sagemath has no build in support for timeout on
function call.

Here is the basic flow of the script: (this is not the real script but
a stripped down version)
----------------------------------------------------------------
#!/usr/bin/env sage

import os, sys, time, datetime, ntpath
import multiprocessing as mp
from sage.all import *

def doTheIntegration(q1,q2):
    problem = q1.get()
    integrand = SR(problem[0])
    theVar = SR(problem[1])
   anti = integrate(integrand,theVar)      
    q2.put(anti)    

if __name__ == "__main__":
   
    integrandAsString = "cos(x)"
    mp.set_start_method('spawn')        
    q1= mp.Queue()
    q2= mp.Queue()

    q1.put([integrandAsString,"x"]) #integrand, variable
    process = mp.Process(target=doTheIntegration, args=(q1,q2,))  
    process.start()                            
    print("after process start()..waiting to finish")                       

    try:
        anti = q2.get(True,4*60) #4 minutes timeout                        
                                
    except Exception as ee:
        print("Exception in call to queue.get ",ee)        
        print("type(exception).__name__=",type(ee).__name__)
                                    
    del(q1)    
    del(q2)    
    process.terminate()             
------------------------------------------------

I run this using  

sage ./script.sage

And see these tmp folders created. Since real script runs in a loop, the 
tmp folders
remain there until the script is done, which takes days.

Is there a way not to create these tmp folders?

Thanks
--Nasser

On Tuesday, August 15, 2023 at 8:28:39 AM UTC-5 Michael Orlitzky wrote:

> On Tue, 2023-08-15 at 03:33 -0700, 'Nasser M. Abbasi' via sage-devel
> wrote:
> > Each time I run a sagemath script, I see 10's of thousands of files 
> created 
> > in my TMPDIR which I have to keep manually deleting.
>
> There aren't too many parts of sage that use temporary files. What's
> the script doing?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/03050696-1388-4469-948e-0dda7fa4e8aen%40googlegroups.com.

Reply via email to