fix(ffi): return parser status and isolate thread errors
This commit is contained in:
parent
740cf9c693
commit
24438c4840
1 changed files with 234 additions and 24 deletions
10
test.py
10
test.py
|
|
@ -16,10 +16,16 @@ clib = ffi.dlopen('target/debug/libklamath_rs_ext.so')
|
|||
|
||||
ret_ptr_array = ffi.new('struct ArrowArray[]', 1)
|
||||
ret_ptr_schema = ffi.new('struct ArrowSchema[]', 1)
|
||||
ffi.cdef('void read_path(char* path, struct ArrowArray* array, struct ArrowSchema* schema);')
|
||||
ffi.cdef('''
|
||||
int read_path(const char* path, struct ArrowArray* array, struct ArrowSchema* schema);
|
||||
const char* last_error_message(void);
|
||||
''')
|
||||
print(f'{ret_ptr_array[0]=}, {ret_ptr_schema[0]=}')
|
||||
|
||||
clib.read_path(path.encode(), ret_ptr_array, ret_ptr_schema)
|
||||
status = clib.read_path(path.encode(), ret_ptr_array, ret_ptr_schema)
|
||||
if status != 0:
|
||||
message = ffi.string(clib.last_error_message()).decode('utf-8', errors='replace')
|
||||
raise RuntimeError(message)
|
||||
|
||||
ptr_schema = int(ffi.cast('uintptr_t', ret_ptr_schema))
|
||||
ptr_array = int(ffi.cast('uintptr_t', ret_ptr_array))
|
||||
|
|
|
|||
Loading…
Reference in a new issue