Python _ctypes.dlclose() Examples

The following are 6 code examples of _ctypes.dlclose(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module _ctypes , or try the search function .
Example #1
Source File: PLCObject.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def _FreePLC(self):
        """
        Unload PLC library.
        This is also called by __init__ to create dummy C func proxies
        """
        self.PLClibraryLock.acquire()
        try:
            # Unload library explicitely
            if getattr(self, "_PLClibraryHandle", None) is not None:
                dlclose(self._PLClibraryHandle)

            # Forget all refs to library
            self._InitPLCStubCalls()

        finally:
            self.PLClibraryLock.release()

        return False 
Example #2
Source File: c.py    From kernel_tuner with Apache License 2.0 5 votes vote down vote up
def cleanup_lib(self):
        """ unload the previously loaded shared library """
        if not self.using_openmp:
            #this if statement is necessary because shared libraries that use
            #OpenMP will core dump when unloaded, this is a well-known issue with OpenMP
            logging.debug('unloading shared library')
            _ctypes.dlclose(self.lib._handle) 
Example #3
Source File: kunpeng.py    From xunfeng with GNU General Public License v3.0 5 votes vote down vote up
def close(self):
        if self.system == 'windows':
            _ctypes.FreeLibrary(self.kunpeng._handle)
        else:
            handle = self.kunpeng._handle
            del self.kunpeng
            _ctypes.dlclose(handle) 
Example #4
Source File: jitcore_gcc.py    From miasm with GNU General Public License v2.0 5 votes vote down vote up
def deleteCB(self, offset):
        """Free the state associated to @offset and delete it
        @offset: gcc state offset
        """
        flib = None
        if is_win:
            flib = _ctypes.FreeLibrary
        else:
            flib = _ctypes.dlclose
        flib(self.states[offset]._handle)
        del self.states[offset] 
Example #5
Source File: uinput.py    From steamcontroller with MIT License 5 votes vote down vote up
def __del__(self):

        if self._lib and self._fd:
            self._lib.uinput_destroy(self._fd)
            self._fd = None
            _ctypes.dlclose(self._lib._handle)
            self._lib = None 
Example #6
Source File: __init__.py    From python-zpar with MIT License 5 votes vote down vote up
def close(self):

        # unload the models on the C++ side
        _unload_models = self.libptr.unload_models
        _unload_models.restype = None
        _unload_models.argtypes = [c.c_void_p]
        self.libptr.unload_models(self._zpar_session_obj)

        # clean up the data structures on the python side
        if self.tagger:
            self.tagger.cleanup()

        if self.parser:
            self.parser.cleanup()

        if self.depparser:
            self.depparser.cleanup()

        # set all the fields to none to enable clean reuse
        self.tagger = None
        self.parser = None
        self.depparser = None
        self.modelpath = None

        # clean up the CDLL object too so that upon reuse, we get a new one
        _ctypes.dlclose(self.libptr._handle)
        # pretty sure once the old object libptr was pointed to should
        # get garbage collected at some point after this
        self.libptr = None
        self._zpar_session_obj = None