Changeset 9acbd37 in sasmodels


Ignore:
Timestamp:
Oct 5, 2016 4:28:54 PM (5 years ago)
Author:
wojciech
Children:
8b10fdf
Parents:
71f8bdb
Message:

Unloading lib from ctypes by triggering release function in kerneldll ref #576

Location:
sasmodels
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kerneldll.py

    rb01a603 r9acbd37  
    7373import tempfile 
    7474import ctypes as ct  # type: ignore 
     75import _ctypes as _ct 
    7576from ctypes import c_void_p, c_int32, c_longdouble, c_double, c_float  # type: ignore 
    7677import logging 
     
    259260        # Note: if there is a syntax error then compile raises an error 
    260261        # and the source file will not be deleted. 
    261         #os.unlink(filename) 
    262         print("saving compiled file in %r"%filename) 
     262        os.unlink(filename) 
     263        #print("saving compiled file in %r"%filename) 
    263264    return dll 
    264265 
     
    301302    def _load_dll(self): 
    302303        # type: () -> None 
    303         print("dll", self.dllpath) 
    304304        try: 
    305305            self._dll = ct.CDLL(self.dllpath) 
     
    344344        Release any resources associated with the model. 
    345345        """ 
     346        dll_handle = self._dll._handle 
    346347        if os.name == 'nt': 
    347             #dll = ct.cdll.LoadLibrary(self.dllpath) 
    348             dll = ct.CDLL(self.dllpath) 
    349             dll_handle = dll._handle 
    350             #dll_handle = ct.c_void_p(dll._handle) 
    351             del dll, self._dll 
    352             self._dll = None 
    353348            ct.windll.kernel32.FreeLibrary(dll_handle) 
    354349        else: 
    355             pass 
    356  
     350            _ct.dlclose(dll_handle) 
     351        del self._dll 
     352        self._dll = None 
    357353 
    358354class DllKernel(Kernel): 
  • sasmodels/sasview_model.py

    r9c1a59c r9acbd37  
    575575                            magnetic=is_magnetic) 
    576576        calculator.release() 
     577        self._model.release() 
    577578        return result 
    578579 
Note: See TracChangeset for help on using the changeset viewer.