All DMS opened by a program are now listed and closed with atexit system

This commit is contained in:
Celine Mercier
2017-10-16 10:35:07 +02:00
parent 5ddd1d9ae6
commit 04e065094a
4 changed files with 101 additions and 4 deletions

View File

@ -17,6 +17,7 @@ cdef extern from "obidms.h" nogil:
int obi_close_dms(OBIDMS_p dms)
char* obi_dms_get_dms_path(OBIDMS_p dms)
char* obi_dms_get_full_path(OBIDMS_p dms, const_char_p path_name)
void obi_close_atexit()
obiversion_t obi_import_column(const char* dms_path_1, const char* dms_path_2, const char* column_name, obiversion_t version_number)
int obi_import_view(const char* dms_path_1, const char* dms_path_2, const char* view_name_1, const char* view_name_2)

View File

@ -1,14 +1,15 @@
#cython: language_level=3
from libc.stdlib cimport free
from libc.stdlib cimport free, atexit
from cpython.list cimport PyList_Size
from .capi.obidms cimport obi_open_dms, \
obi_create_dms, \
obi_close_dms, \
obi_dms_exists, \
obi_dms_get_full_path
obi_dms_get_full_path, \
obi_close_atexit
from .capi.obitypes cimport const_char_p
@ -30,6 +31,10 @@ cdef class DMS(OBIWrapper):
cdef inline OBIDMS_p pointer(self):
return <OBIDMS_p>(self._pointer)
@staticmethod
def obi_atexit():
atexit(obi_close_atexit)
@staticmethod
def open_or_new(object dms_name) :
cdef OBIDMS_p pointer