From 79e2aab7dd5a37165160a0e3ca469e6fd6b5d536 Mon Sep 17 00:00:00 2001 From: Tommaso Pino Date: Wed, 5 May 2021 17:50:22 +0200 Subject: [PATCH 01/14] definition of locking decorator --- spiceypy/spiceypy.py | 612 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 610 insertions(+), 2 deletions(-) diff --git a/spiceypy/spiceypy.py b/spiceypy/spiceypy.py index 24978294..536d6c02 100644 --- a/spiceypy/spiceypy.py +++ b/spiceypy/spiceypy.py @@ -74,6 +74,33 @@ _SPICE_EK_MAXQSEL = 100 # Twice the 50 in gcc-linux-64 _SPICE_EK_EKRCEX_ROOM_DEFAULT = 100 # Enough? +import threading + +spicelock = threading.Lock() + +def spicelock_for_multithread(f): + """ + :return: + """ + + @functools.wraps(f) + def lock(*args, **kwargs): + + if not spicelock.locked(): + spicelock.acquire() + try: + # this try handle if some error occurs + res = f(*args, **kwargs) + finally: + if spicelock.locked(): + spicelock.release() + else: + # some library methods calls other library methods, this "else" handle that + res = f(*args, **kwargs) + + return res + + return lock def check_for_spice_error(f: Optional[Callable]) -> None: """ @@ -258,6 +285,7 @@ def cell_time(cell_size) -> SpiceCell: # A +@spicelock_for_multithread @spice_error_check def appndc( item: Union[str, Iterable[str], ndarray, str_], @@ -280,6 +308,7 @@ def appndc( libspice.appndc_c(item, cell) +@spicelock_for_multithread @spice_error_check def appndd( item: Union[float, Iterable[float]], cell: Union[SpiceCell, Cell_Double] @@ -301,6 +330,7 @@ def appndd( libspice.appndd_c(item, cell) +@spicelock_for_multithread @spice_error_check def appndi(item: Union[Iterable[int], int], cell: Union[SpiceCell, Cell_Int]) -> None: """ @@ -320,6 +350,7 @@ def appndi(item: Union[Iterable[int], int], cell: Union[SpiceCell, Cell_Int]) -> libspice.appndi_c(item, cell) +@spicelock_for_multithread @spice_error_check def axisar(axis: Union[ndarray, Iterable[float]], angle: float) -> ndarray: """ @@ -343,6 +374,7 @@ def axisar(axis: Union[ndarray, Iterable[float]], angle: float) -> ndarray: # B +@spicelock_for_multithread @spice_error_check def b1900() -> float: """ @@ -355,6 +387,7 @@ def b1900() -> float: return libspice.b1900_c() +@spicelock_for_multithread @spice_error_check def b1950() -> float: """ @@ -367,6 +400,7 @@ def b1950() -> float: return libspice.b1950_c() +@spicelock_for_multithread @spice_error_check def badkpv( caller: str, name: str, comp: str, insize: int, divby: int, intype: str @@ -394,6 +428,7 @@ def badkpv( return bool(libspice.badkpv_c(caller, name, comp, insize, divby, intype)) +@spicelock_for_multithread @spice_error_check def bltfrm(frmcls: int, out_cell: Optional[SpiceCell] = None) -> SpiceCell: """ @@ -413,6 +448,7 @@ def bltfrm(frmcls: int, out_cell: Optional[SpiceCell] = None) -> SpiceCell: return out_cell +@spicelock_for_multithread @spice_error_check def bodeul(body: int, et: float) -> Tuple[float, float, float, float]: """ @@ -447,6 +483,7 @@ def bodeul(body: int, et: float) -> Tuple[float, float, float, float]: return ra.value, dec.value, w.value, lam.value +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def bodc2n(code: int, lenout: int = _default_len_out) -> Tuple[str, bool]: @@ -468,6 +505,7 @@ def bodc2n(code: int, lenout: int = _default_len_out) -> Tuple[str, bool]: return stypes.to_python_string(name), bool(found.value) +@spicelock_for_multithread @spice_error_check def bodc2s(code: int, lenout: int = _default_len_out) -> str: """ @@ -488,6 +526,7 @@ def bodc2s(code: int, lenout: int = _default_len_out) -> str: return stypes.to_python_string(name) +@spicelock_for_multithread @spice_error_check def boddef(name: str, code: int) -> None: """ @@ -504,6 +543,7 @@ def boddef(name: str, code: int) -> None: libspice.boddef_c(name, code) +@spicelock_for_multithread @spice_error_check def bodfnd(body: int, item: str) -> bool: """ @@ -521,6 +561,7 @@ def bodfnd(body: int, item: str) -> bool: return bool(libspice.bodfnd_c(body, item)) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def bodn2c(name: str) -> Tuple[int, bool]: @@ -540,6 +581,7 @@ def bodn2c(name: str) -> Tuple[int, bool]: return code.value, bool(found.value) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def bods2c(name: str) -> Tuple[int, bool]: @@ -558,6 +600,7 @@ def bods2c(name: str) -> Tuple[int, bool]: return code.value, bool(found.value) +@spicelock_for_multithread @spice_error_check def bodvar(body: int, item: str, dim: int) -> ndarray: """ @@ -584,6 +627,7 @@ def bodvar(body: int, item: str, dim: int) -> ndarray: return stypes.c_vector_to_python(values) +@spicelock_for_multithread @spice_error_check def bodvcd(bodyid: int, item: str, maxn: int) -> Tuple[int, ndarray]: """ @@ -609,6 +653,7 @@ def bodvcd(bodyid: int, item: str, maxn: int) -> Tuple[int, ndarray]: return dim.value, stypes.c_vector_to_python(values) +@spicelock_for_multithread @spice_error_check def bodvrd(bodynm: str, item: str, maxn: int) -> Tuple[int, ndarray]: """ @@ -633,6 +678,7 @@ def bodvrd(bodynm: str, item: str, maxn: int) -> Tuple[int, ndarray]: return dim.value, stypes.c_vector_to_python(values) +@spicelock_for_multithread @spice_error_check def brcktd(number: float, end1: float, end2: float) -> float: """ @@ -654,6 +700,7 @@ def brcktd(number: float, end1: float, end2: float) -> float: return libspice.brcktd_c(number, end1, end2) +@spicelock_for_multithread @spice_error_check def brckti(number: int, end1: int, end2: int) -> int: """ @@ -675,6 +722,7 @@ def brckti(number: int, end1: int, end2: int) -> int: return libspice.brckti_c(number, end1, end2) +@spicelock_for_multithread @spice_error_check def bschoc( value: Union[str_, str], @@ -705,6 +753,7 @@ def bschoc( return libspice.bschoc_c(value, ndim, lenvals, array, order) +@spicelock_for_multithread @spice_error_check def bschoi(value: int, ndim: int, array: Iterable[int], order: Iterable[int]) -> int: """ @@ -727,6 +776,7 @@ def bschoi(value: int, ndim: int, array: Iterable[int], order: Iterable[int]) -> return libspice.bschoi_c(value, ndim, array, order) +@spicelock_for_multithread @spice_error_check def bsrchc(value: str, ndim: int, lenvals: int, array: Iterable[str]) -> int: """ @@ -749,6 +799,7 @@ def bsrchc(value: str, ndim: int, lenvals: int, array: Iterable[str]) -> int: return libspice.bsrchc_c(value, ndim, lenvals, array) +@spicelock_for_multithread @spice_error_check def bsrchd(value: float, ndim: int, array: ndarray) -> int: """ @@ -769,6 +820,7 @@ def bsrchd(value: float, ndim: int, array: ndarray) -> int: return libspice.bsrchd_c(value, ndim, array) +@spicelock_for_multithread @spice_error_check def bsrchi(value: int, ndim: int, array: ndarray) -> int: """ @@ -793,6 +845,7 @@ def bsrchi(value: int, ndim: int, array: ndarray) -> int: # C +@spicelock_for_multithread @spice_error_check def card(cell: SpiceCell) -> int: """ @@ -807,6 +860,7 @@ def card(cell: SpiceCell) -> int: return libspice.card_c(ctypes.byref(cell)) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def ccifrm( @@ -850,6 +904,7 @@ def ccifrm( ) +@spicelock_for_multithread @spice_error_check def cgv2el( center: Iterable[float], @@ -874,6 +929,7 @@ def cgv2el( return ellipse +@spicelock_for_multithread @spice_error_check def chbder( cp: Iterable[float], degp: int, x2s: Iterable[float], x: float, nderiv: int @@ -903,6 +959,7 @@ def chbder( return stypes.c_vector_to_python(dpdxs) +@spicelock_for_multithread @spice_error_check def chkin(module: str) -> None: """ @@ -916,6 +973,7 @@ def chkin(module: str) -> None: libspice.chkin_c(module) +@spicelock_for_multithread @spice_error_check def chkout(module: str) -> None: """ @@ -929,6 +987,7 @@ def chkout(module: str) -> None: libspice.chkout_c(module) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def cidfrm(cent: int, lenout: int = _default_len_out) -> Tuple[int, str, bool]: @@ -952,6 +1011,7 @@ def cidfrm(cent: int, lenout: int = _default_len_out) -> Tuple[int, str, bool]: return frcode.value, stypes.to_python_string(frname), bool(found.value) +@spicelock_for_multithread @spice_error_check def ckcls(handle: int) -> None: """ @@ -965,6 +1025,7 @@ def ckcls(handle: int) -> None: libspice.ckcls_c(handle) +@spicelock_for_multithread @spice_error_check def ckcov( ck: str, @@ -1003,6 +1064,7 @@ def ckcov( return cover +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def ckfrot(inst: int, et: float) -> Tuple[ndarray, int, bool]: @@ -1031,6 +1093,7 @@ def ckfrot(inst: int, et: float) -> Tuple[ndarray, int, bool]: return stypes.c_matrix_to_numpy(rotate_m), ref.value, bool(found.value) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def ckgp( @@ -1062,6 +1125,7 @@ def ckgp( return stypes.c_matrix_to_numpy(cmat), clkout.value, bool(found.value) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def ckgpav( @@ -1101,6 +1165,7 @@ def ckgpav( ) +@spicelock_for_multithread @spice_error_check def cklpf(filename: str) -> int: """ @@ -1119,6 +1184,7 @@ def cklpf(filename: str) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def ckobj(ck: str, out_cell: Optional[SpiceCell] = None) -> SpiceCell: """ @@ -1140,6 +1206,7 @@ def ckobj(ck: str, out_cell: Optional[SpiceCell] = None) -> SpiceCell: return out_cell +@spicelock_for_multithread @spice_error_check def ckopn(filename: str, ifname: str, ncomch: int) -> int: """ @@ -1160,6 +1227,7 @@ def ckopn(filename: str, ifname: str, ncomch: int) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def ckupf(handle: int) -> None: """ @@ -1174,6 +1242,7 @@ def ckupf(handle: int) -> None: libspice.ckupf_c(handle) +@spicelock_for_multithread @spice_error_check def ckw01( handle: int, @@ -1221,6 +1290,7 @@ def ckw01( ) +@spicelock_for_multithread @spice_error_check def ckw02( handle: int, @@ -1271,6 +1341,7 @@ def ckw02( ) +@spicelock_for_multithread @spice_error_check def ckw03( handle: int, @@ -1336,6 +1407,7 @@ def ckw03( ) +@spicelock_for_multithread @spice_error_check def ckw05( handle: int, @@ -1411,6 +1483,7 @@ def cleard() -> NotImplementedError: raise NotImplementedError +@spicelock_for_multithread @spice_error_check def clight() -> float: """ @@ -1423,6 +1496,7 @@ def clight() -> float: return libspice.clight_c() +@spicelock_for_multithread @spice_error_check def clpool() -> None: """ @@ -1434,6 +1508,7 @@ def clpool() -> None: libspice.clpool_c() +@spicelock_for_multithread @spice_error_check def cltext(fname: str) -> None: """ @@ -1463,6 +1538,7 @@ def cltext(fname: str) -> None: libspice.cltext_(fname_p, fname_len) +@spicelock_for_multithread @spice_error_check def cmprss(delim: str, n: int, instr: str, lenout: int = _default_len_out) -> str: """ @@ -1486,6 +1562,7 @@ def cmprss(delim: str, n: int, instr: str, lenout: int = _default_len_out) -> st return stypes.to_python_string(output) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def cnmfrm(cname: str, lenout: int = _default_len_out) -> Tuple[int, str, bool]: @@ -1509,6 +1586,7 @@ def cnmfrm(cname: str, lenout: int = _default_len_out) -> Tuple[int, str, bool]: return frcode.value, stypes.to_python_string(frname), bool(found.value) +@spicelock_for_multithread @spice_error_check def conics(elts: ndarray, et: float) -> ndarray: """ @@ -1529,6 +1607,7 @@ def conics(elts: ndarray, et: float) -> ndarray: return stypes.c_vector_to_python(state) +@spicelock_for_multithread @spice_error_check def convrt( x: Union[float, Iterable[float]], inunit: str, outunit: str @@ -1562,6 +1641,7 @@ def convrt( return y.value +@spicelock_for_multithread @spice_error_check def copy(cell: SpiceCell) -> SpiceCell: """ @@ -1588,6 +1668,7 @@ def copy(cell: SpiceCell) -> SpiceCell: return newcopy +@spicelock_for_multithread @spice_error_check def cpos(string: str, chars: str, start: int) -> int: """ @@ -1610,6 +1691,7 @@ def cpos(string: str, chars: str, start: int) -> int: return libspice.cpos_c(string, chars, start) +@spicelock_for_multithread @spice_error_check def cposr(string: str, chars: str, start: int) -> int: """ @@ -1632,6 +1714,7 @@ def cposr(string: str, chars: str, start: int) -> int: return libspice.cposr_c(string, chars, start) +@spicelock_for_multithread @spice_error_check def cvpool(agent: str) -> bool: """ @@ -1649,6 +1732,7 @@ def cvpool(agent: str) -> bool: return bool(update.value) +@spicelock_for_multithread @spice_error_check def cyllat(r: float, lonc: float, z: float) -> Tuple[float, float, float]: """ @@ -1673,6 +1757,7 @@ def cyllat(r: float, lonc: float, z: float) -> Tuple[float, float, float]: return radius.value, lon.value, lat.value +@spicelock_for_multithread @spice_error_check def cylrec(r: float, lon: float, z: float) -> ndarray: """ @@ -1693,6 +1778,7 @@ def cylrec(r: float, lon: float, z: float) -> ndarray: return stypes.c_vector_to_python(rectan) +@spicelock_for_multithread @spice_error_check def cylsph(r: float, lonc: float, z: float) -> Tuple[float, float, float]: """ @@ -1724,6 +1810,7 @@ def cylsph(r: float, lonc: float, z: float) -> Tuple[float, float, float]: # D +@spicelock_for_multithread @spice_error_check def dafac(handle: int, buffer: Sequence[str]) -> None: """ @@ -1743,6 +1830,7 @@ def dafac(handle: int, buffer: Sequence[str]) -> None: libspice.dafac_c(handle, n, lenvals, buffer) +@spicelock_for_multithread @spice_error_check def dafbbs(handle: int) -> None: """ @@ -1756,6 +1844,7 @@ def dafbbs(handle: int) -> None: libspice.dafbbs_c(handle) +@spicelock_for_multithread @spice_error_check def dafbfs(handle: int) -> None: """ @@ -1769,6 +1858,7 @@ def dafbfs(handle: int) -> None: libspice.dafbfs_c(handle) +@spicelock_for_multithread @spice_error_check def dafcls(handle: int) -> None: """ @@ -1782,6 +1872,7 @@ def dafcls(handle: int) -> None: libspice.dafcls_c(handle) +@spicelock_for_multithread @spice_error_check def dafcs(handle: int) -> None: """ @@ -1796,6 +1887,7 @@ def dafcs(handle: int) -> None: libspice.dafcs_c(handle) +@spicelock_for_multithread @spice_error_check def dafdc(handle: int) -> None: """ @@ -1809,6 +1901,7 @@ def dafdc(handle: int) -> None: libspice.dafdc_c(handle) +@spicelock_for_multithread @spice_error_check def dafec( handle: int, bufsiz: int, lenout: int = _default_len_out @@ -1843,6 +1936,7 @@ def dafec( return n.value, stypes.c_vector_to_python(buffer), bool(done.value) +@spicelock_for_multithread @spice_error_check def daffna() -> bool: """ @@ -1857,6 +1951,7 @@ def daffna() -> bool: return bool(found.value) +@spicelock_for_multithread @spice_error_check def daffpa() -> bool: """ @@ -1871,6 +1966,7 @@ def daffpa() -> bool: return bool(found.value) +@spicelock_for_multithread @spice_error_check def dafgda(handle: int, begin: int, end: int) -> ndarray: """ @@ -1891,6 +1987,7 @@ def dafgda(handle: int, begin: int, end: int) -> ndarray: return stypes.c_vector_to_python(data) +@spicelock_for_multithread @spice_error_check def dafgh() -> int: """ @@ -1905,6 +2002,7 @@ def dafgh() -> int: return outvalue.value +@spicelock_for_multithread @spice_error_check def dafgn(lenout: int = _default_len_out) -> str: """ @@ -1921,6 +2019,7 @@ def dafgn(lenout: int = _default_len_out) -> str: return stypes.to_python_string(name) +@spicelock_for_multithread @spice_error_check def dafgs(n: int = 125) -> ndarray: # The 125 may be a hard set, @@ -1939,6 +2038,7 @@ def dafgs(n: int = 125) -> ndarray: return stypes.c_vector_to_python(retarray)[0:n] +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def dafgsr(handle: int, recno: int, begin: int, end: int) -> Tuple[ndarray, bool]: @@ -1964,6 +2064,7 @@ def dafgsr(handle: int, recno: int, begin: int, end: int) -> Tuple[ndarray, bool return stypes.c_vector_to_python(data), bool(found.value) +@spicelock_for_multithread @spice_error_check def dafopr(fname: str) -> int: """ @@ -1980,6 +2081,7 @@ def dafopr(fname: str) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def dafopw(fname: str) -> int: """ @@ -1996,6 +2098,7 @@ def dafopw(fname: str) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def dafps(nd: int, ni: int, dc: ndarray, ic: ndarray) -> ndarray: """ @@ -2019,6 +2122,7 @@ def dafps(nd: int, ni: int, dc: ndarray, ic: ndarray) -> ndarray: return stypes.c_vector_to_python(outsum) +@spicelock_for_multithread @spice_error_check def dafrda(handle: int, begin: int, end: int) -> ndarray: """ @@ -2043,6 +2147,7 @@ def dafrda(handle: int, begin: int, end: int) -> ndarray: return stypes.c_vector_to_python(data) +@spicelock_for_multithread @spice_error_check def dafrfr( handle: int, lenout: int = _default_len_out @@ -2089,6 +2194,7 @@ def dafrfr( ) +@spicelock_for_multithread @spice_error_check def dafrs(insum: ndarray) -> None: """ @@ -2102,6 +2208,7 @@ def dafrs(insum: ndarray) -> None: libspice.dafrs_c(ctypes.byref(insum)) +@spicelock_for_multithread @spice_error_check def dafus(insum: ndarray, nd: int, ni: int) -> Tuple[ndarray, ndarray]: """ @@ -2123,6 +2230,7 @@ def dafus(insum: ndarray, nd: int, ni: int) -> Tuple[ndarray, ndarray]: return stypes.c_vector_to_python(dc), stypes.c_vector_to_python(ic) +@spicelock_for_multithread @spice_error_check def dasac(handle: int, buffer: Sequence[str]) -> None: """ @@ -2142,6 +2250,7 @@ def dasac(handle: int, buffer: Sequence[str]) -> None: libspice.dasac_c(handle, n, buflen, buffer) +@spicelock_for_multithread @spice_error_check def dascls(handle: int) -> None: """ @@ -2155,6 +2264,7 @@ def dascls(handle: int) -> None: libspice.dascls_c(handle) +@spicelock_for_multithread @spice_error_check def dasdc(handle: int) -> None: """ @@ -2169,6 +2279,7 @@ def dasdc(handle: int) -> None: libspice.dasdc_c(handle) +@spicelock_for_multithread @spice_error_check def dasec( handle: int, bufsiz: int = _default_len_out, buflen: int = _default_len_out @@ -2203,6 +2314,7 @@ def dasec( return n.value, stypes.c_vector_to_python(buffer), done.value +@spicelock_for_multithread @spice_error_check def dashfn(handle: int, lenout: int = _default_len_out) -> str: """ @@ -2221,6 +2333,7 @@ def dashfn(handle: int, lenout: int = _default_len_out) -> str: return stypes.to_python_string(fname) +@spicelock_for_multithread @spice_error_check def dasonw(fname: str, ftype: str, ifname: str, ncomch: int) -> int: """ @@ -2253,6 +2366,7 @@ def dasonw(fname: str, ftype: str, ifname: str, ncomch: int) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def dasopr(fname: str) -> int: """ @@ -2269,6 +2383,7 @@ def dasopr(fname: str) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def dasopw(fname: str) -> int: """ @@ -2284,6 +2399,7 @@ def dasopw(fname: str) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def dasrfr( handle: int, lenout: int = _default_len_out @@ -2329,6 +2445,7 @@ def dasrfr( ) +@spicelock_for_multithread @spice_error_check def dcyldr(x: float, y: float, z: float) -> ndarray: """ @@ -2350,6 +2467,7 @@ def dcyldr(x: float, y: float, z: float) -> ndarray: return stypes.c_matrix_to_numpy(jacobi) +@spicelock_for_multithread @spice_error_check def deltet(epoch: float, eptype: str) -> float: """ @@ -2368,6 +2486,7 @@ def deltet(epoch: float, eptype: str) -> float: return delta.value +@spicelock_for_multithread @spice_error_check def det(m1: ndarray) -> float: """ @@ -2382,6 +2501,7 @@ def det(m1: ndarray) -> float: return libspice.det_c(m1) +@spicelock_for_multithread @spice_error_check def dgeodr(x: float, y: float, z: float, re: float, f: float) -> ndarray: """ @@ -2407,6 +2527,7 @@ def dgeodr(x: float, y: float, z: float, re: float, f: float) -> ndarray: return stypes.c_matrix_to_numpy(jacobi) +@spicelock_for_multithread @spice_error_check def diags2(symmat: Iterable[Iterable[float]]) -> Tuple[ndarray, ndarray]: """ @@ -2426,6 +2547,7 @@ def diags2(symmat: Iterable[Iterable[float]]) -> Tuple[ndarray, ndarray]: return stypes.c_matrix_to_numpy(diag), stypes.c_matrix_to_numpy(rotateout) +@spicelock_for_multithread @spice_error_check def diff(a: SpiceCell, b: SpiceCell) -> SpiceCell: """ @@ -2453,6 +2575,7 @@ def diff(a: SpiceCell, b: SpiceCell) -> SpiceCell: return c +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def dlabbs(handle: int) -> Tuple[SpiceDLADescr, bool]: @@ -2471,6 +2594,7 @@ def dlabbs(handle: int) -> Tuple[SpiceDLADescr, bool]: return descr, bool(found.value) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def dlabfs(handle: int) -> Tuple[SpiceDLADescr, bool]: @@ -2489,6 +2613,7 @@ def dlabfs(handle: int) -> Tuple[SpiceDLADescr, bool]: return descr, bool(found.value) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def dlafns(handle: int, descr: SpiceDLADescr) -> Tuple[SpiceDLADescr, bool]: @@ -2511,6 +2636,7 @@ def dlafns(handle: int, descr: SpiceDLADescr) -> Tuple[SpiceDLADescr, bool]: return nxtdsc, bool(found.value) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def dlafps(handle: int, descr: SpiceDLADescr) -> Tuple[SpiceDLADescr, bool]: @@ -2533,6 +2659,7 @@ def dlafps(handle: int, descr: SpiceDLADescr) -> Tuple[SpiceDLADescr, bool]: return prvdsc, bool(found.value) +@spicelock_for_multithread @spice_error_check def dlatdr(x: float, y: float, z: float) -> ndarray: """ @@ -2554,6 +2681,7 @@ def dlatdr(x: float, y: float, z: float) -> ndarray: return stypes.c_matrix_to_numpy(jacobi) +@spicelock_for_multithread @spice_error_check def dp2hx(number: float, lenout: int = _default_len_out) -> str: """ @@ -2574,6 +2702,7 @@ def dp2hx(number: float, lenout: int = _default_len_out) -> str: return stypes.to_python_string(string) +@spicelock_for_multithread @spice_error_check def dpgrdr(body: str, x: float, y: float, z: int, re: float, f: float) -> ndarray: """ @@ -2601,6 +2730,7 @@ def dpgrdr(body: str, x: float, y: float, z: int, re: float, f: float) -> ndarra return stypes.c_matrix_to_numpy(jacobi) +@spicelock_for_multithread @spice_error_check def dpmax() -> float: """ @@ -2616,6 +2746,7 @@ def dpmax() -> float: return libspice.dpmax_c() +@spicelock_for_multithread @spice_error_check def dpmin() -> float: """ @@ -2631,6 +2762,7 @@ def dpmin() -> float: return libspice.dpmin_c() +@spicelock_for_multithread @spice_error_check def dpr() -> float: """ @@ -2643,6 +2775,7 @@ def dpr() -> float: return libspice.dpr_c() +@spicelock_for_multithread @spice_error_check def drdcyl(r: float, lon: float, z: float) -> ndarray: """ @@ -2664,6 +2797,7 @@ def drdcyl(r: float, lon: float, z: float) -> ndarray: return stypes.c_matrix_to_numpy(jacobi) +@spicelock_for_multithread @spice_error_check def drdgeo(lon: float, lat: float, alt: float, re: float, f: float) -> ndarray: """ @@ -2689,6 +2823,7 @@ def drdgeo(lon: float, lat: float, alt: float, re: float, f: float) -> ndarray: return stypes.c_matrix_to_numpy(jacobi) +@spicelock_for_multithread @spice_error_check def drdlat(r: float, lon: float, lat: float) -> ndarray: """ @@ -2710,6 +2845,7 @@ def drdlat(r: float, lon: float, lat: float) -> ndarray: return stypes.c_matrix_to_numpy(jacobi) +@spicelock_for_multithread @spice_error_check def drdpgr(body: str, lon: float, lat: float, alt: int, re: float, f: float) -> ndarray: """ @@ -2737,6 +2873,7 @@ def drdpgr(body: str, lon: float, lat: float, alt: int, re: float, f: float) -> return stypes.c_matrix_to_numpy(jacobi) +@spicelock_for_multithread @spice_error_check def drdsph(r: float, colat: float, lon: float) -> ndarray: """ @@ -2758,6 +2895,7 @@ def drdsph(r: float, colat: float, lon: float) -> ndarray: return stypes.c_matrix_to_numpy(jacobi) +@spicelock_for_multithread @spice_error_check def dskb02( handle: int, dladsc: SpiceDLADescr @@ -2814,6 +2952,7 @@ def dskb02( ) +@spicelock_for_multithread @spice_error_check def dskcls(handle: int, optmiz: bool = False) -> None: """ @@ -2830,6 +2969,7 @@ def dskcls(handle: int, optmiz: bool = False) -> None: libspice.dskcls_c(handle, optmiz) +@spicelock_for_multithread @spice_error_check def dskd02( handle: int, dladsc: SpiceDLADescr, item: int, start: int, room: int @@ -2857,6 +2997,7 @@ def dskd02( return stypes.c_vector_to_python(values) +@spicelock_for_multithread @spice_error_check def dskgd(handle: int, dladsc: SpiceDLADescr) -> SpiceDSKDescr: """ @@ -2875,6 +3016,7 @@ def dskgd(handle: int, dladsc: SpiceDLADescr) -> SpiceDSKDescr: return dskdsc +@spicelock_for_multithread @spice_error_check def dskgtl(keywrd: int) -> float: """ @@ -2891,6 +3033,7 @@ def dskgtl(keywrd: int) -> float: return dpval.value +@spicelock_for_multithread @spice_error_check def dski02( handle: int, dladsc: SpiceDLADescr, item: int, start: int, room: int @@ -2917,6 +3060,7 @@ def dski02( return stypes.c_matrix_to_numpy(values) +@spicelock_for_multithread @spice_error_check def dskmi2( vrtces: ndarray, @@ -2981,6 +3125,7 @@ def dskmi2( return stypes.c_vector_to_python(spaixd), stypes.c_vector_to_python(spaixi) +@spicelock_for_multithread @spice_error_check def dskn02(handle: int, dladsc: SpiceDLADescr, plid: int) -> ndarray: """ @@ -3001,6 +3146,7 @@ def dskn02(handle: int, dladsc: SpiceDLADescr, plid: int) -> ndarray: return stypes.c_vector_to_python(normal) +@spicelock_for_multithread @spice_error_check def dskobj(dsk: str) -> SpiceCell: """ @@ -3018,6 +3164,7 @@ def dskobj(dsk: str) -> SpiceCell: return bodids +@spicelock_for_multithread @spice_error_check def dskopn(fname: str, ifname: str, ncomch: int) -> int: """ @@ -3038,6 +3185,7 @@ def dskopn(fname: str, ifname: str, ncomch: int) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def dskp02(handle: int, dladsc: SpiceDLADescr, start: int, room: int) -> ndarray: """ @@ -3061,6 +3209,7 @@ def dskp02(handle: int, dladsc: SpiceDLADescr, start: int, room: int) -> ndarray return stypes.c_matrix_to_numpy(plates) +@spicelock_for_multithread @spice_error_check def dskrb2( vrtces: ndarray, plates: ndarray, corsys: int, corpar: ndarray @@ -3099,6 +3248,7 @@ def dskrb2( return mncor3.value, mxcor3.value +@spicelock_for_multithread @spice_error_check def dsksrf(dsk: str, bodyid: int) -> SpiceCell: """ @@ -3118,6 +3268,7 @@ def dsksrf(dsk: str, bodyid: int) -> SpiceCell: return srfids +@spicelock_for_multithread @spice_error_check def dskstl(keywrd: int, dpval: float) -> None: """ @@ -3134,6 +3285,7 @@ def dskstl(keywrd: int, dpval: float) -> None: libspice.dskstl_c(keywrd, dpval) +@spicelock_for_multithread @spice_error_check def dskv02(handle: int, dladsc: SpiceDLADescr, start: int, room: int) -> ndarray: """ @@ -3156,6 +3308,7 @@ def dskv02(handle: int, dladsc: SpiceDLADescr, start: int, room: int) -> ndarray return stypes.c_matrix_to_numpy(vrtces) +@spicelock_for_multithread @spice_error_check def dskw02( handle: int, @@ -3249,6 +3402,7 @@ def dskw02( ) +@spicelock_for_multithread @spice_error_check def dskx02( handle: int, dladsc: SpiceDLADescr, vertex: ndarray, raydir: ndarray @@ -3284,6 +3438,7 @@ def dskx02( return plid.value, stypes.c_vector_to_python(xpt), bool(found.value) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def dskxsi( @@ -3360,6 +3515,7 @@ def dskxsi( ) +@spicelock_for_multithread @spice_error_check def dskxv( pri: bool, @@ -3402,6 +3558,7 @@ def dskxv( return stypes.c_matrix_to_numpy(xptarr), stypes.c_vector_to_python(fndarr) +@spicelock_for_multithread @spice_error_check def dskz02(handle: int, dladsc: SpiceDLADescr) -> Tuple[int, int]: """ @@ -3421,6 +3578,7 @@ def dskz02(handle: int, dladsc: SpiceDLADescr) -> Tuple[int, int]: return nv.value, np.value +@spicelock_for_multithread @spice_error_check def dsphdr(x: float, y: float, z: float) -> ndarray: """ @@ -3443,6 +3601,7 @@ def dsphdr(x: float, y: float, z: float) -> ndarray: return stypes.c_matrix_to_numpy(jacobi) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def dtpool(name: str) -> Tuple[int, str, bool]: @@ -3464,6 +3623,7 @@ def dtpool(name: str) -> Tuple[int, str, bool]: return n.value, stypes.to_python_string(typeout.value), bool(found.value) +@spicelock_for_multithread @spice_error_check def ducrss(s1: ndarray, s2: ndarray) -> ndarray: """ @@ -3484,6 +3644,7 @@ def ducrss(s1: ndarray, s2: ndarray) -> ndarray: return stypes.c_vector_to_python(sout) +@spicelock_for_multithread @spice_error_check def dvcrss(s1: ndarray, s2: ndarray) -> ndarray: """ @@ -3504,6 +3665,7 @@ def dvcrss(s1: ndarray, s2: ndarray) -> ndarray: return stypes.c_vector_to_python(sout) +@spicelock_for_multithread @spice_error_check def dvdot(s1: Sequence[float], s2: Sequence[float]) -> float: """ @@ -3522,6 +3684,7 @@ def dvdot(s1: Sequence[float], s2: Sequence[float]) -> float: return libspice.dvdot_c(s1, s2) +@spicelock_for_multithread @spice_error_check def dvhat(s1: ndarray) -> ndarray: """ @@ -3540,6 +3703,7 @@ def dvhat(s1: ndarray) -> ndarray: return stypes.c_vector_to_python(sout) +@spicelock_for_multithread @spice_error_check def dvnorm(state: ndarray) -> float: """ @@ -3556,6 +3720,7 @@ def dvnorm(state: ndarray) -> float: return libspice.dvnorm_c(state) +@spicelock_for_multithread @spice_error_check def dvpool(name: str) -> None: """ @@ -3569,6 +3734,7 @@ def dvpool(name: str) -> None: libspice.dvpool_c(name) +@spicelock_for_multithread @spice_error_check def dvsep(s1: ndarray, s2: ndarray) -> float: """ @@ -3591,6 +3757,7 @@ def dvsep(s1: ndarray, s2: ndarray) -> float: # E +@spicelock_for_multithread @spice_error_check def edlimb( a: float, @@ -3618,6 +3785,7 @@ def edlimb( return limb +@spicelock_for_multithread @spice_error_check def edterm( trmtyp: str, @@ -3680,6 +3848,7 @@ def edterm( ) +@spicelock_for_multithread @spice_error_check def ekacec( handle: int, @@ -3714,6 +3883,7 @@ def ekacec( libspice.ekacec_c(handle, segno, recno, column, nvals, vallen, cvals, isnull) +@spicelock_for_multithread @spice_error_check def ekaced( handle: int, @@ -3747,6 +3917,7 @@ def ekaced( libspice.ekaced_c(handle, segno, recno, column, nvals, dvals, isnull) +@spicelock_for_multithread @spice_error_check def ekacei( handle: int, @@ -3780,6 +3951,7 @@ def ekacei( libspice.ekacei_c(handle, segno, recno, column, nvals, ivals, isnull) +@spicelock_for_multithread @spice_error_check def ekaclc( handle: int, @@ -3823,6 +3995,7 @@ def ekaclc( return stypes.c_vector_to_python(wkindx) +@spicelock_for_multithread @spice_error_check def ekacld( handle: int, @@ -3861,6 +4034,7 @@ def ekacld( return stypes.c_vector_to_python(wkindx) +@spicelock_for_multithread @spice_error_check def ekacli( handle: int, @@ -3899,6 +4073,7 @@ def ekacli( return stypes.c_vector_to_python(wkindx) +@spicelock_for_multithread @spice_error_check def ekappr(handle: int, segno: int) -> int: """ @@ -3917,6 +4092,7 @@ def ekappr(handle: int, segno: int) -> int: return recno.value +@spicelock_for_multithread @spice_error_check def ekbseg( handle: int, tabnam: str, cnames: Sequence[str], decls: Sequence[str] @@ -3948,6 +4124,7 @@ def ekbseg( return segno.value +@spicelock_for_multithread @spice_error_check def ekccnt(table: str) -> int: """ @@ -3965,6 +4142,7 @@ def ekccnt(table: str) -> int: return ccount.value +@spicelock_for_multithread @spice_error_check def ekcii( table: str, cindex: int, lenout: int = _default_len_out @@ -3989,6 +4167,7 @@ def ekcii( return stypes.to_python_string(column), attdsc +@spicelock_for_multithread @spice_error_check def ekcls(handle: int) -> None: """ @@ -4002,6 +4181,7 @@ def ekcls(handle: int) -> None: libspice.ekcls_c(handle) +@spicelock_for_multithread @spice_error_check def ekdelr(handle: int, segno: int, recno: int) -> None: """ @@ -4019,6 +4199,7 @@ def ekdelr(handle: int, segno: int, recno: int) -> None: libspice.ekdelr_c(handle, segno, recno) +@spicelock_for_multithread @spice_error_check def ekffld(handle: int, segno: int, rcptrs: ndarray) -> None: """ @@ -4036,6 +4217,7 @@ def ekffld(handle: int, segno: int, rcptrs: ndarray) -> None: libspice.ekffld_c(handle, segno, ctypes.cast(rcptrs, ctypes.POINTER(ctypes.c_int))) +@spicelock_for_multithread @spice_error_check def ekfind(query: str, lenout: int = _default_len_out) -> Tuple[int, int, str]: """ @@ -4059,6 +4241,7 @@ def ekfind(query: str, lenout: int = _default_len_out) -> Tuple[int, int, str]: return nmrows.value, error.value, stypes.to_python_string(errmsg) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def ekgc( @@ -4091,6 +4274,7 @@ def ekgc( return stypes.to_python_string(cdata), null.value, bool(found.value) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def ekgd(selidx: int, row: int, element: int) -> Tuple[float, int, bool]: @@ -4124,6 +4308,7 @@ def ekgd(selidx: int, row: int, element: int) -> Tuple[float, int, bool]: return ddata.value, null.value, bool(found.value) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def ekgi(selidx: int, row: int, element: int) -> Tuple[int, int, bool]: @@ -4157,6 +4342,7 @@ def ekgi(selidx: int, row: int, element: int) -> Tuple[int, int, bool]: return idata.value, null.value, bool(found.value) +@spicelock_for_multithread @spice_error_check def ekifld( handle: int, @@ -4208,6 +4394,7 @@ def ekifld( return segno.value, stypes.c_vector_to_python(recptrs) +@spicelock_for_multithread @spice_error_check def ekinsr(handle: int, segno: int, recno: int) -> None: """ @@ -4226,6 +4413,7 @@ def ekinsr(handle: int, segno: int, recno: int) -> None: libspice.ekinsr_c(handle, segno, recno) +@spicelock_for_multithread @spice_error_check def eklef(fname: str) -> int: """ @@ -4242,6 +4430,7 @@ def eklef(fname: str) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def eknelt(selidx: int, row: int) -> int: """ @@ -4259,6 +4448,7 @@ def eknelt(selidx: int, row: int) -> int: return libspice.eknelt_c(selidx, row) +@spicelock_for_multithread @spice_error_check def eknseg(handle: int) -> int: """ @@ -4273,6 +4463,7 @@ def eknseg(handle: int) -> int: return libspice.eknseg_c(handle) +@spicelock_for_multithread @spice_error_check def ekntab() -> int: """ @@ -4287,6 +4478,7 @@ def ekntab() -> int: return n.value +@spicelock_for_multithread @spice_error_check def ekopn(fname: str, ifname: str, ncomch: int) -> int: """ @@ -4307,6 +4499,7 @@ def ekopn(fname: str, ifname: str, ncomch: int) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def ekopr(fname: str) -> int: """ @@ -4323,6 +4516,7 @@ def ekopr(fname: str) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def ekops() -> int: """ @@ -4338,6 +4532,7 @@ def ekops() -> int: return handle.value +@spicelock_for_multithread @spice_error_check def ekopw(fname: str) -> int: """ @@ -4354,6 +4549,7 @@ def ekopw(fname: str) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def ekpsel( query: str, msglen: int, tablen: int, collen: int @@ -4423,6 +4619,7 @@ def ekpsel( ) +@spicelock_for_multithread @spice_error_check def ekrcec( handle: int, @@ -4474,6 +4671,7 @@ def ekrcec( ) +@spicelock_for_multithread @spice_error_check def ekrced( handle: int, @@ -4515,6 +4713,7 @@ def ekrced( ) +@spicelock_for_multithread @spice_error_check def ekrcei( handle: int, @@ -4556,6 +4755,7 @@ def ekrcei( ) +@spicelock_for_multithread @spice_error_check def ekssum(handle: int, segno: int) -> SpiceEKSegSum: """ @@ -4574,6 +4774,7 @@ def ekssum(handle: int, segno: int) -> SpiceEKSegSum: return segsum +@spicelock_for_multithread @spice_error_check def ektnam(n: int, lenout: int = _default_len_out) -> str: """ @@ -4592,6 +4793,7 @@ def ektnam(n: int, lenout: int = _default_len_out) -> str: return stypes.to_python_string(table) +@spicelock_for_multithread @spice_error_check def ekucec( handle: int, @@ -4626,6 +4828,7 @@ def ekucec( libspice.ekucec_c(handle, segno, recno, column, nvals, vallen, cvals, isnull) +@spicelock_for_multithread @spice_error_check def ekuced( handle: int, @@ -4659,6 +4862,7 @@ def ekuced( libspice.ekaced_c(handle, segno, recno, column, nvals, dvals, isnull) +@spicelock_for_multithread @spice_error_check def ekucei( handle: int, @@ -4692,6 +4896,7 @@ def ekucei( libspice.ekucei_c(handle, segno, recno, column, nvals, ivals, isnull) +@spicelock_for_multithread @spice_error_check def ekuef(handle: int) -> None: """ @@ -4707,6 +4912,7 @@ def ekuef(handle: int) -> None: libspice.ekuef_c(handle) +@spicelock_for_multithread @spice_error_check def el2cgv(ellipse: Ellipse) -> Tuple[ndarray, ndarray, ndarray]: """ @@ -4731,6 +4937,7 @@ def el2cgv(ellipse: Ellipse) -> Tuple[ndarray, ndarray, ndarray]: ) +@spicelock_for_multithread @spice_error_check def elemc(item: str, inset: SpiceCell) -> bool: """ @@ -4747,6 +4954,7 @@ def elemc(item: str, inset: SpiceCell) -> bool: return bool(libspice.elemc_c(item, ctypes.byref(inset))) +@spicelock_for_multithread @spice_error_check def elemd(item: float, inset: SpiceCell) -> bool: """ @@ -4764,6 +4972,7 @@ def elemd(item: float, inset: SpiceCell) -> bool: return bool(libspice.elemd_c(item, ctypes.byref(inset))) +@spicelock_for_multithread @spice_error_check def elemi(item: int, inset: SpiceCell) -> bool: """ @@ -4781,6 +4990,7 @@ def elemi(item: int, inset: SpiceCell) -> bool: return bool(libspice.elemi_c(item, ctypes.byref(inset))) +@spicelock_for_multithread @spice_error_check def eqncpv( et: float, @@ -4813,6 +5023,7 @@ def eqncpv( return stypes.c_vector_to_python(state) +@spicelock_for_multithread @spice_error_check def eqstr(a: str, b: str) -> bool: """ @@ -4956,6 +5167,7 @@ def esrchc(value: str, array: Sequence[str]) -> int: return libspice.esrchc_c(value, ndim, lenvals, array) +@spicelock_for_multithread @spice_error_check def et2lst( et: float, @@ -5017,6 +5229,7 @@ def et2lst( ) +@spicelock_for_multithread @spice_error_check def et2utc( et: Union[float, Iterable[float]], @@ -5052,6 +5265,7 @@ def et2utc( return stypes.to_python_string(utcstr) +@spicelock_for_multithread @spice_error_check def etcal( et: Union[float, ndarray], lenout: int = _default_len_out @@ -5082,6 +5296,7 @@ def etcal( return stypes.to_python_string(string) +@spicelock_for_multithread @spice_error_check def eul2m( angle3: float, angle2: float, angle1: float, axis3: int, axis2: int, axis1: int @@ -5110,6 +5325,7 @@ def eul2m( return stypes.c_matrix_to_numpy(r) +@spicelock_for_multithread @spice_error_check def eul2xf(eulang: Sequence[float], axisa: int, axisb: int, axisc: int) -> ndarray: """ @@ -5135,6 +5351,7 @@ def eul2xf(eulang: Sequence[float], axisa: int, axisb: int, axisc: int) -> ndarr return stypes.c_matrix_to_numpy(xform) +@spicelock_for_multithread @spice_error_check def ev2lin(et: float, geophs: Sequence[float], elems: Sequence[float]) -> ndarray: """ @@ -5159,6 +5376,7 @@ def ev2lin(et: float, geophs: Sequence[float], elems: Sequence[float]) -> ndarra return stypes.c_vector_to_python(state) +@spicelock_for_multithread @spice_error_check def exists(fname: str) -> bool: """ @@ -5173,6 +5391,7 @@ def exists(fname: str) -> bool: return bool(libspice.exists_c(fname)) +@spicelock_for_multithread @spice_error_check def expool(name: str) -> bool: """ @@ -5204,6 +5423,7 @@ def failed() -> bool: return bool(libspice.failed_c()) +@spicelock_for_multithread @spice_error_check def fn2lun(fname: str) -> int: """ @@ -5222,6 +5442,7 @@ def fn2lun(fname: str) -> int: return unit_out.value +@spicelock_for_multithread @spice_error_check def fovray( inst: str, @@ -5258,6 +5479,7 @@ def fovray( return bool(visible.value) +@spicelock_for_multithread @spice_error_check def fovtrg( inst: str, @@ -5304,6 +5526,7 @@ def fovtrg( return bool(visible.value) +@spicelock_for_multithread @spice_error_check def frame(x: Iterable[float]) -> Tuple[ndarray, ndarray, ndarray]: """ @@ -5323,6 +5546,7 @@ def frame(x: Iterable[float]) -> Tuple[ndarray, ndarray, ndarray]: ) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def frinfo(frcode: int) -> Tuple[int, int, int, bool]: @@ -5347,6 +5571,7 @@ def frinfo(frcode: int) -> Tuple[int, int, int, bool]: return cent.value, frclss.value, clssid.value, bool(found.value) +@spicelock_for_multithread @spice_error_check def frmnam(frcode: int, lenout: int = _default_len_out) -> str: """ @@ -5365,6 +5590,7 @@ def frmnam(frcode: int, lenout: int = _default_len_out) -> str: return stypes.to_python_string(frname) +@spicelock_for_multithread @spice_error_check def ftncls(unit: int) -> None: """ @@ -5378,6 +5604,7 @@ def ftncls(unit: int) -> None: libspice.ftncls_c(unit) +@spicelock_for_multithread @spice_error_check def furnsh(path: Union[str, Iterable[str]]) -> None: """ @@ -5399,6 +5626,7 @@ def furnsh(path: Union[str, Iterable[str]]) -> None: # G +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def gcpool( @@ -5437,6 +5665,7 @@ def gcpool( ) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def gdpool(name: str, start: int, room: int) -> Tuple[ndarray, bool]: @@ -5467,6 +5696,7 @@ def gdpool(name: str, start: int, room: int) -> Tuple[ndarray, bool]: return stypes.c_vector_to_python(values)[0 : n.value], bool(found.value) +@spicelock_for_multithread @spice_error_check def georec(lon: float, lat: float, alt: float, re: float, f: float) -> ndarray: """ @@ -5494,6 +5724,7 @@ def georec(lon: float, lat: float, alt: float, re: float, f: float) -> ndarray: # getcml not really needed +@spicelock_for_multithread @spice_error_check def getelm(frstyr: int, lineln: int, lines: Iterable[str]) -> Tuple[float, ndarray]: """ @@ -5519,6 +5750,7 @@ def getelm(frstyr: int, lineln: int, lines: Iterable[str]) -> Tuple[float, ndarr return epoch.value, stypes.c_vector_to_python(elems) +@spicelock_for_multithread @spice_error_check def getfat(file: str) -> Tuple[str, str]: """ @@ -5538,6 +5770,7 @@ def getfat(file: str) -> Tuple[str, str]: return stypes.to_python_string(arch), stypes.to_python_string(rettype) +@spicelock_for_multithread @spice_error_check def getfov( instid: int, @@ -5602,6 +5835,7 @@ def getmsg(option: str, lenout: int = _default_len_out) -> str: return stypes.to_python_string(msg) +@spicelock_for_multithread @spice_error_check def gfbail() -> bool: """ @@ -5614,6 +5848,7 @@ def gfbail() -> bool: return bool(libspice.gfbail_c()) +@spicelock_for_multithread @spice_error_check def gfclrh() -> None: """ @@ -5626,6 +5861,7 @@ def gfclrh() -> None: libspice.gfclrh_c() +@spicelock_for_multithread @spice_error_check def gfdist( target: str, @@ -5686,6 +5922,7 @@ def gfdist( return result +@spicelock_for_multithread @spice_error_check def gfevnt( udstep: UDSTEP, @@ -5792,6 +6029,7 @@ def gfevnt( return result +@spicelock_for_multithread @spice_error_check def gffove( inst: str, @@ -5880,6 +6118,7 @@ def gffove( return result +@spicelock_for_multithread @spice_error_check def gfilum( method: str, @@ -5959,6 +6198,7 @@ def gfilum( return result +@spicelock_for_multithread @spice_error_check def gfinth(sigcode: int) -> None: """ @@ -5974,6 +6214,7 @@ def gfinth(sigcode: int) -> None: libspice.gfinth_c(sigcode) +@spicelock_for_multithread @spice_error_check def gfocce( occtyp: str, @@ -6072,6 +6313,7 @@ def gfocce( return result +@spicelock_for_multithread @spice_error_check def gfoclt( occtyp: str, @@ -6140,6 +6382,7 @@ def gfoclt( return result +@spicelock_for_multithread @spice_error_check def gfpa( target: str, @@ -6205,6 +6448,7 @@ def gfpa( return result +@spicelock_for_multithread @spice_error_check def gfposc( target: str, @@ -6277,6 +6521,7 @@ def gfposc( return result +@spicelock_for_multithread @spice_error_check def gfrefn(t1: float, t2: float, s1: Union[bool, int], s2: Union[bool, int]) -> float: """ @@ -6300,6 +6545,7 @@ def gfrefn(t1: float, t2: float, s1: Union[bool, int], s2: Union[bool, int]) -> return t.value +@spicelock_for_multithread @spice_error_check def gfrepf() -> None: """ @@ -6311,6 +6557,7 @@ def gfrepf() -> None: libspice.gfrepf_c() +@spicelock_for_multithread @spice_error_check def gfrepi( window: Union[SpiceCell, SpiceCellPointer], begmss: str, endmss: str @@ -6334,6 +6581,7 @@ def gfrepi( libspice.gfrepi_c(window, begmss, endmss) +@spicelock_for_multithread @spice_error_check def gfrepu(ivbeg: float, ivend: float, time: float) -> None: """ @@ -6352,6 +6600,7 @@ def gfrepu(ivbeg: float, ivend: float, time: float) -> None: libspice.gfrepu_c(ivbeg, ivend, time) +@spicelock_for_multithread @spice_error_check def gfrfov( inst: str, @@ -6405,6 +6654,7 @@ def gfrfov( return result +@spicelock_for_multithread @spice_error_check def gfrr( target: str, @@ -6465,6 +6715,7 @@ def gfrr( return result +@spicelock_for_multithread @spice_error_check def gfsep( targ1: str, @@ -6546,6 +6797,7 @@ def gfsep( return result +@spicelock_for_multithread @spice_error_check def gfsntc( target: str, @@ -6630,6 +6882,7 @@ def gfsntc( return result +@spicelock_for_multithread @spice_error_check def gfsstp(step: float) -> None: """ @@ -6643,6 +6896,7 @@ def gfsstp(step: float) -> None: libspice.gfsstp_c(step) +@spicelock_for_multithread @spice_error_check def gfstep(time: float) -> float: """ @@ -6659,6 +6913,7 @@ def gfstep(time: float) -> float: return step.value +@spicelock_for_multithread @spice_error_check def gfstol(value: float) -> None: """ @@ -6675,6 +6930,7 @@ def gfstol(value: float) -> None: libspice.gfstol_c(value) +@spicelock_for_multithread @spice_error_check def gfsubc( target: str, @@ -6751,6 +7007,7 @@ def gfsubc( return result +@spicelock_for_multithread @spice_error_check def gftfov( inst: str, @@ -6809,6 +7066,7 @@ def gftfov( return result +@spicelock_for_multithread @spice_error_check def gfudb( udfuns: UDFUNS, udfunb: UDFUNB, step: float, cnfine: SpiceCell, result: SpiceCell @@ -6829,6 +7087,7 @@ def gfudb( libspice.gfudb_c(udfuns, udfunb, step, ctypes.byref(cnfine), ctypes.byref(result)) +@spicelock_for_multithread @spice_error_check def gfuds( udfuns: UDFUNS, @@ -6876,6 +7135,7 @@ def gfuds( return result +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def gipool(name: str, start: int, room: int) -> Tuple[ndarray, bool]: @@ -6899,6 +7159,7 @@ def gipool(name: str, start: int, room: int) -> Tuple[ndarray, bool]: return stypes.c_vector_to_python(ivals)[0 : n.value], bool(found.value) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def gnpool( @@ -6932,6 +7193,7 @@ def gnpool( # H +@spicelock_for_multithread @spice_error_check def halfpi() -> float: """ @@ -6945,6 +7207,7 @@ def halfpi() -> float: return libspice.halfpi_c() +@spicelock_for_multithread @spice_error_check def hrmint( xvals: Sequence[float], yvals: Sequence[float], x: int @@ -6971,6 +7234,7 @@ def hrmint( return f.value, df.value +@spicelock_for_multithread @spice_error_check def hx2dp(string: str) -> Union[float, str]: """ @@ -6999,6 +7263,7 @@ def hx2dp(string: str) -> Union[float, str]: # I +@spicelock_for_multithread @spice_error_check def ident() -> ndarray: """ @@ -7013,6 +7278,7 @@ def ident() -> ndarray: return stypes.c_matrix_to_numpy(matrix) +@spicelock_for_multithread @spice_error_check def illum( target: str, et: float, abcorr: str, obsrvr: str, spoint: ndarray @@ -7058,6 +7324,7 @@ def illum( return phase.value, solar.value, emissn.value +@spicelock_for_multithread @spice_error_check def illumf( method: str, @@ -7139,6 +7406,7 @@ def illumf( ) +@spicelock_for_multithread @spice_error_check def illumg( method: str, @@ -7211,6 +7479,7 @@ def illumg( ) +@spicelock_for_multithread @spice_error_check def ilumin( method: str, @@ -7275,6 +7544,7 @@ def ilumin( ) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def inedpl(a: float, b: float, c: float, plane: Plane) -> Tuple[Ellipse, bool]: @@ -7301,6 +7571,7 @@ def inedpl(a: float, b: float, c: float, plane: Plane) -> Tuple[Ellipse, bool]: return ellipse, bool(found.value) +@spicelock_for_multithread @spice_error_check def inelpl(ellips: Ellipse, plane: Plane) -> Tuple[int, ndarray, ndarray]: """ @@ -7326,6 +7597,7 @@ def inelpl(ellips: Ellipse, plane: Plane) -> Tuple[int, ndarray, ndarray]: return nxpts.value, stypes.c_vector_to_python(xpt1), stypes.c_vector_to_python(xpt2) +@spicelock_for_multithread @spice_error_check def inrypl( vertex: Iterable[Union[float, float]], @@ -7354,6 +7626,7 @@ def inrypl( return nxpts.value, stypes.c_vector_to_python(xpt) +@spicelock_for_multithread @spice_error_check def insrtc(item: Union[str, Iterable[str]], inset: SpiceCell) -> None: """ @@ -7373,6 +7646,7 @@ def insrtc(item: Union[str, Iterable[str]], inset: SpiceCell) -> None: libspice.insrtc_c(item, ctypes.byref(inset)) +@spicelock_for_multithread @spice_error_check def insrtd(item: Union[float, Iterable[float]], inset: SpiceCell) -> None: """ @@ -7392,6 +7666,7 @@ def insrtd(item: Union[float, Iterable[float]], inset: SpiceCell) -> None: libspice.insrtd_c(item, ctypes.byref(inset)) +@spicelock_for_multithread @spice_error_check def insrti(item: Union[Iterable[int], int], inset: SpiceCell) -> None: """ @@ -7411,6 +7686,7 @@ def insrti(item: Union[Iterable[int], int], inset: SpiceCell) -> None: libspice.insrti_c(item, ctypes.byref(inset)) +@spicelock_for_multithread @spice_error_check def inter(a: SpiceCell, b: SpiceCell) -> SpiceCell: """ @@ -7439,6 +7715,7 @@ def inter(a: SpiceCell, b: SpiceCell) -> SpiceCell: return c +@spicelock_for_multithread @spice_error_check def intmax() -> int: """ @@ -7452,6 +7729,7 @@ def intmax() -> int: return libspice.intmax_c() +@spicelock_for_multithread @spice_error_check def intmin() -> int: """ @@ -7465,6 +7743,7 @@ def intmin() -> int: return libspice.intmin_c() +@spicelock_for_multithread @spice_error_check def invert(m: ndarray) -> ndarray: """ @@ -7481,6 +7760,7 @@ def invert(m: ndarray) -> ndarray: return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def invort(m: ndarray) -> ndarray: """ @@ -7499,6 +7779,7 @@ def invort(m: ndarray) -> ndarray: return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def irfnam(index: int) -> str: """ @@ -7517,6 +7798,7 @@ def irfnam(index: int) -> str: return stypes.to_python_string(name) +@spicelock_for_multithread @spice_error_check def irfnum(name: str) -> int: """ @@ -7535,6 +7817,7 @@ def irfnum(name: str) -> int: return index.value +@spicelock_for_multithread @spice_error_check def irfrot(refa: int, refb: int) -> ndarray: """ @@ -7555,6 +7838,7 @@ def irfrot(refa: int, refb: int) -> ndarray: return stypes.c_matrix_to_numpy(rotab).T +@spicelock_for_multithread @spice_error_check def irftrn(refa: str, refb: str) -> ndarray: """ @@ -7577,6 +7861,7 @@ def irftrn(refa: str, refb: str) -> ndarray: return stypes.c_matrix_to_numpy(rotab).T +@spicelock_for_multithread @spice_error_check def isordv(array: Iterable[int], n: int) -> bool: """ @@ -7596,6 +7881,7 @@ def isordv(array: Iterable[int], n: int) -> bool: return bool(libspice.isordv_c(array, n)) +@spicelock_for_multithread @spice_error_check def isrchc(value: str, ndim: int, lenvals: int, array: Iterable[str]) -> int: """ @@ -7620,6 +7906,7 @@ def isrchc(value: str, ndim: int, lenvals: int, array: Iterable[str]) -> int: return libspice.isrchc_c(value, ndim, lenvals, array) +@spicelock_for_multithread @spice_error_check def isrchd(value: float, ndim: int, array: Iterable[float]) -> int: """ @@ -7642,6 +7929,7 @@ def isrchd(value: float, ndim: int, array: Iterable[float]) -> int: return libspice.isrchd_c(value, ndim, array) +@spicelock_for_multithread @spice_error_check def isrchi(value: int, ndim: int, array: Iterable[int]) -> int: """ @@ -7664,6 +7952,7 @@ def isrchi(value: int, ndim: int, array: Iterable[int]) -> int: return libspice.isrchi_c(value, ndim, array) +@spicelock_for_multithread @spice_error_check def isrot(m: ndarray, ntol: float, dtol: float) -> bool: """ @@ -7684,6 +7973,7 @@ def isrot(m: ndarray, ntol: float, dtol: float) -> bool: return bool(libspice.isrot_c(m, ntol, dtol)) +@spicelock_for_multithread @spice_error_check def iswhsp(string: str) -> bool: """ @@ -7705,6 +7995,7 @@ def iswhsp(string: str) -> bool: # J +@spicelock_for_multithread @spice_error_check def j1900() -> float: """ @@ -7715,6 +8006,7 @@ def j1900() -> float: return libspice.j1900_c() +@spicelock_for_multithread @spice_error_check def j1950() -> float: """ @@ -7725,6 +8017,7 @@ def j1950() -> float: return libspice.j1950_c() +@spicelock_for_multithread @spice_error_check def j2000() -> float: """ @@ -7735,6 +8028,7 @@ def j2000() -> float: return libspice.j2000_c() +@spicelock_for_multithread @spice_error_check def j2100() -> float: """ @@ -7745,6 +8039,7 @@ def j2100() -> float: return libspice.j2100_c() +@spicelock_for_multithread @spice_error_check def jyear() -> float: """ @@ -7759,6 +8054,7 @@ def jyear() -> float: # K +@spicelock_for_multithread @spice_error_check def kclear() -> None: """ @@ -7772,6 +8068,7 @@ def kclear() -> None: libspice.kclear_c() +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def kdata( @@ -7828,6 +8125,7 @@ def kdata( ) +@spicelock_for_multithread @spice_error_check def kepleq(ml: float, h: float, k: float) -> float: """ @@ -7847,6 +8145,7 @@ def kepleq(ml: float, h: float, k: float) -> float: return f +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def kinfo( @@ -7883,6 +8182,7 @@ def kinfo( ) +@spicelock_for_multithread @spice_error_check def kplfrm(frmcls: int, out_cell: Optional[SpiceCell] = None) -> SpiceCell: """ @@ -7902,6 +8202,7 @@ def kplfrm(frmcls: int, out_cell: Optional[SpiceCell] = None) -> SpiceCell: return out_cell +@spicelock_for_multithread @spice_error_check def kpsolv(evec: Tuple[float, float]) -> float: """ @@ -7919,6 +8220,7 @@ def kpsolv(evec: Tuple[float, float]) -> float: return x +@spicelock_for_multithread @spice_error_check def ktotal(kind: str) -> int: """ @@ -7936,6 +8238,7 @@ def ktotal(kind: str) -> int: return count.value +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def kxtrct( @@ -8001,6 +8304,7 @@ def kxtrct( # L +@spicelock_for_multithread @spice_error_check def lastnb(string: str) -> int: """ @@ -8016,6 +8320,7 @@ def lastnb(string: str) -> int: return libspice.lastnb_c(string) +@spicelock_for_multithread @spice_error_check def latcyl(radius: float, lon: float, lat: float) -> Tuple[float, float, float]: """ @@ -8040,6 +8345,7 @@ def latcyl(radius: float, lon: float, lat: float) -> Tuple[float, float, float]: return r.value, lonc.value, z.value +@spicelock_for_multithread @spice_error_check def latrec( radius: float, longitude: Union[float, float], latitude: Union[float, float] @@ -8062,6 +8368,7 @@ def latrec( return stypes.c_vector_to_python(rectan) +@spicelock_for_multithread @spice_error_check def latsph(radius: float, lon: float, lat: float) -> Tuple[float, float, float]: """ @@ -8086,6 +8393,7 @@ def latsph(radius: float, lon: float, lat: float) -> Tuple[float, float, float]: return rho.value, colat.value, lons.value +@spicelock_for_multithread @spice_error_check def latsrf( method: str, target: str, et: float, fixref: str, lonlat: Sequence[Sequence[float]] @@ -8117,6 +8425,7 @@ def latsrf( return stypes.c_matrix_to_numpy(srfpts) +@spicelock_for_multithread @spice_error_check def lcase(instr: str, lenout: int = _default_len_out) -> str: """ @@ -8135,6 +8444,7 @@ def lcase(instr: str, lenout: int = _default_len_out) -> str: return stypes.to_python_string(outstr) +@spicelock_for_multithread @spice_error_check def ldpool(filename: str) -> None: """ @@ -8149,6 +8459,7 @@ def ldpool(filename: str) -> None: libspice.ldpool_c(filename) +@spicelock_for_multithread @spice_error_check def limbpt( method: str, @@ -8238,6 +8549,7 @@ def limbpt( ) +@spicelock_for_multithread @spice_error_check def lgrind( xvals: Sequence[float], yvals: Sequence[float], x: float @@ -8265,6 +8577,7 @@ def lgrind( return p.value, dp.value +@spicelock_for_multithread @spice_error_check def lmpool(cvals: Union[ndarray, Iterable[str]]) -> None: """ @@ -8281,6 +8594,7 @@ def lmpool(cvals: Union[ndarray, Iterable[str]]) -> None: libspice.lmpool_c(cvals, lenvals, n) +@spicelock_for_multithread @spice_error_check def lparse(inlist: str, delim: str, nmax: int) -> Iterable[str]: """ @@ -8303,6 +8617,7 @@ def lparse(inlist: str, delim: str, nmax: int) -> Iterable[str]: return [stypes.to_python_string(x.value) for x in items[0 : n.value]] +@spicelock_for_multithread @spice_error_check def lparsm( inlist: str, delims: str, nmax: int, lenout: Optional[int] = None @@ -8331,6 +8646,7 @@ def lparsm( return [stypes.to_python_string(x.value) for x in items][0 : n.value] +@spicelock_for_multithread @spice_error_check def lparss(inlist: str, delims: str, nmax: int = 20, length: int = 50) -> SpiceCell: """ @@ -8352,6 +8668,7 @@ def lparss(inlist: str, delims: str, nmax: int = 20, length: int = 50) -> SpiceC return return_set +@spicelock_for_multithread @spice_error_check def lspcn(body: str, et: float, abcorr: str) -> float: """ @@ -8371,6 +8688,7 @@ def lspcn(body: str, et: float, abcorr: str) -> float: return libspice.lspcn_c(body, et, abcorr) +@spicelock_for_multithread @spice_error_check def lstlec(string: str, n: int, lenvals: int, array: Iterable[str]) -> int: """ @@ -8395,6 +8713,7 @@ def lstlec(string: str, n: int, lenvals: int, array: Iterable[str]) -> int: return libspice.lstlec_c(string, n, lenvals, array) +@spicelock_for_multithread @spice_error_check def lstled(x: float, n: int, array: Iterable[float]) -> int: """ @@ -8414,6 +8733,7 @@ def lstled(x: float, n: int, array: Iterable[float]) -> int: return libspice.lstled_c(x, n, array) +@spicelock_for_multithread @spice_error_check def lstlei(x: int, n: int, array: Iterable[int]) -> int: """ @@ -8433,6 +8753,7 @@ def lstlei(x: int, n: int, array: Iterable[int]) -> int: return libspice.lstlei_c(x, n, array) +@spicelock_for_multithread @spice_error_check def lstltc(string: str, n: int, lenvals: int, array: Iterable[str]) -> int: """ @@ -8457,6 +8778,7 @@ def lstltc(string: str, n: int, lenvals: int, array: Iterable[str]) -> int: return libspice.lstltc_c(string, n, lenvals, array) +@spicelock_for_multithread @spice_error_check def lstltd(x: float, n: int, array: Iterable[float]) -> int: """ @@ -8476,6 +8798,7 @@ def lstltd(x: float, n: int, array: Iterable[float]) -> int: return libspice.lstltd_c(x, n, array) +@spicelock_for_multithread @spice_error_check def lstlti(x: int, n: int, array: Iterable[int]) -> int: """ @@ -8495,6 +8818,7 @@ def lstlti(x: int, n: int, array: Iterable[int]) -> int: return libspice.lstlti_c(x, n, array) +@spicelock_for_multithread @spice_error_check def ltime(etobs: float, obs: int, direct: str, targ: int) -> Tuple[float, float]: """ @@ -8523,6 +8847,7 @@ def ltime(etobs: float, obs: int, direct: str, targ: int) -> Tuple[float, float] return ettarg.value, elapsd.value +@spicelock_for_multithread @spice_error_check def lx4dec(string: str, first: int) -> Tuple[int, int]: """ @@ -8543,6 +8868,7 @@ def lx4dec(string: str, first: int) -> Tuple[int, int]: return last.value, nchar.value +@spicelock_for_multithread @spice_error_check def lx4num(string: str, first: int) -> Tuple[int, int]: """ @@ -8563,6 +8889,7 @@ def lx4num(string: str, first: int) -> Tuple[int, int]: return last.value, nchar.value +@spicelock_for_multithread @spice_error_check def lx4sgn(string: str, first: int) -> Tuple[int, int]: """ @@ -8583,6 +8910,7 @@ def lx4sgn(string: str, first: int) -> Tuple[int, int]: return last.value, nchar.value +@spicelock_for_multithread @spice_error_check def lx4uns(string: str, first: int) -> Tuple[int, int]: """ @@ -8603,6 +8931,7 @@ def lx4uns(string: str, first: int) -> Tuple[int, int]: return last.value, nchar.value +@spicelock_for_multithread @spice_error_check def lxqstr(string: str, qchar: str, first: int) -> Tuple[int, int]: """ @@ -8628,6 +8957,7 @@ def lxqstr(string: str, qchar: str, first: int) -> Tuple[int, int]: # M +@spicelock_for_multithread @spice_error_check def m2eul( r: Iterable[Iterable[float]], axis3: int, axis2: int, axis1: int @@ -8663,6 +8993,7 @@ def m2eul( return angle3.value, angle2.value, angle1.value +@spicelock_for_multithread @spice_error_check def m2q(r: ndarray) -> ndarray: """ @@ -8679,6 +9010,7 @@ def m2q(r: ndarray) -> ndarray: return stypes.c_vector_to_python(q) +@spicelock_for_multithread @spice_error_check def matchi(string: str, templ: str, wstr: str, wchr: str) -> bool: """ @@ -8700,6 +9032,7 @@ def matchi(string: str, templ: str, wstr: str, wchr: str) -> bool: return bool(libspice.matchi_c(string, templ, wstr, wchr)) +@spicelock_for_multithread @spice_error_check def matchw(string: str, templ: str, wstr: str, wchr: str) -> bool: # ctypes.c_char(wstr.encode(encoding='UTF-8') @@ -8729,6 +9062,7 @@ def matchw(string: str, templ: str, wstr: str, wchr: str) -> bool: # odd as arguments must be parsed and not really important +@spicelock_for_multithread @spice_error_check def mequ(m1: ndarray) -> ndarray: """ @@ -8745,6 +9079,7 @@ def mequ(m1: ndarray) -> ndarray: return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def mequg(m1: ndarray, nr: int, nc: int) -> ndarray: """ @@ -8773,6 +9108,7 @@ def mequg(m1: ndarray, nr: int, nc: int) -> ndarray: # odd as arguments must be parsed and not really important +@spicelock_for_multithread @spice_error_check def mtxm(m1: ndarray, m2: ndarray) -> ndarray: """ @@ -8791,6 +9127,7 @@ def mtxm(m1: ndarray, m2: ndarray) -> ndarray: return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def mtxmg(m1: ndarray, m2: ndarray, ncol1: int, nr1r2: int, ncol2: int) -> ndarray: """ @@ -8816,6 +9153,7 @@ def mtxmg(m1: ndarray, m2: ndarray, ncol1: int, nr1r2: int, ncol2: int) -> ndarr return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def mtxv(m1: ndarray, vin: ndarray) -> ndarray: """ @@ -8835,6 +9173,7 @@ def mtxv(m1: ndarray, vin: ndarray) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def mtxvg(m1: ndarray, v2: ndarray, ncol1: int, nr1r2: int) -> ndarray: """ @@ -8858,6 +9197,7 @@ def mtxvg(m1: ndarray, v2: ndarray, ncol1: int, nr1r2: int) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def mxm(m1: Iterable[Iterable[float]], m2: Iterable[Iterable[float]]) -> ndarray: """ @@ -8876,6 +9216,7 @@ def mxm(m1: Iterable[Iterable[float]], m2: Iterable[Iterable[float]]) -> ndarray return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def mxmg( m1: Iterable[Iterable[float]], @@ -8906,6 +9247,7 @@ def mxmg( return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def mxmt(m1: Iterable[Iterable[float]], m2: Iterable[Iterable[float]]) -> ndarray: """ @@ -8924,6 +9266,7 @@ def mxmt(m1: Iterable[Iterable[float]], m2: Iterable[Iterable[float]]) -> ndarra return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def mxmtg(m1: ndarray, m2: ndarray, nrow1: int, nc1c2: int, nrow2: int) -> ndarray: """ @@ -8948,6 +9291,7 @@ def mxmtg(m1: ndarray, m2: ndarray, nrow1: int, nc1c2: int, nrow2: int) -> ndarr return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def mxv(m1: ndarray, vin: ndarray) -> ndarray: """ @@ -8967,6 +9311,7 @@ def mxv(m1: ndarray, vin: ndarray) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def mxvg(m1: ndarray, v2: ndarray, nrow1: int, nc1r2: int) -> ndarray: """ @@ -8993,6 +9338,7 @@ def mxvg(m1: ndarray, v2: ndarray, nrow1: int, nc1r2: int) -> ndarray: # N +@spicelock_for_multithread @spice_error_check def namfrm(frname: str) -> int: """ @@ -9009,6 +9355,7 @@ def namfrm(frname: str) -> int: return frcode.value +@spicelock_for_multithread @spice_error_check def ncpos(string: str, chars: str, start: int) -> int: """ @@ -9029,6 +9376,7 @@ def ncpos(string: str, chars: str, start: int) -> int: return libspice.ncpos_c(string, chars, start) +@spicelock_for_multithread @spice_error_check def ncposr(string: str, chars: str, start: int) -> int: """ @@ -9049,6 +9397,7 @@ def ncposr(string: str, chars: str, start: int) -> int: return libspice.ncposr_c(string, chars, start) +@spicelock_for_multithread @spice_error_check def nearpt( positn: Iterable[float], a: float, b: float, c: float @@ -9078,6 +9427,7 @@ def nearpt( return stypes.c_vector_to_python(npoint), alt.value +@spicelock_for_multithread @spice_error_check def npedln( a: float, b: float, c: float, linept: Iterable[float], linedr: Iterable[float] @@ -9106,6 +9456,7 @@ def npedln( return stypes.c_vector_to_python(pnear), dist.value +@spicelock_for_multithread @spice_error_check def npelpt(point: Iterable[float], ellips: Ellipse) -> Tuple[ndarray, float]: """ @@ -9126,6 +9477,7 @@ def npelpt(point: Iterable[float], ellips: Ellipse) -> Tuple[ndarray, float]: return stypes.c_vector_to_python(pnear), dist.value +@spicelock_for_multithread @spice_error_check def nplnpt( linpt: Iterable[float], lindir: Iterable[float], point: Iterable[float] @@ -9152,6 +9504,7 @@ def nplnpt( return stypes.c_vector_to_python(pnear), dist.value +@spicelock_for_multithread @spice_error_check def nvc2pl(normal: Union[Iterable[float], Iterable[float]], constant: float) -> Plane: """ @@ -9170,6 +9523,7 @@ def nvc2pl(normal: Union[Iterable[float], Iterable[float]], constant: float) -> return plane +@spicelock_for_multithread @spice_error_check def nvp2pl(normal: Iterable[float], point: Iterable[float]) -> Plane: """ @@ -9192,6 +9546,7 @@ def nvp2pl(normal: Iterable[float], point: Iterable[float]) -> Plane: # O +@spicelock_for_multithread @spice_error_check def occult( target1: str, @@ -9247,6 +9602,7 @@ def occult( return occult_code.value +@spicelock_for_multithread @spice_error_check def ordc(item: str, inset: SpiceCell) -> int: """ @@ -9267,6 +9623,7 @@ def ordc(item: str, inset: SpiceCell) -> int: return libspice.ordc_c(item, ctypes.byref(inset)) +@spicelock_for_multithread @spice_error_check def ordd(item: float, inset: SpiceCell) -> int: """ @@ -9286,6 +9643,7 @@ def ordd(item: float, inset: SpiceCell) -> int: return libspice.ordd_c(item, ctypes.byref(inset)) +@spicelock_for_multithread @spice_error_check def ordi(item: int, inset: SpiceCell) -> int: """ @@ -9306,6 +9664,7 @@ def ordi(item: int, inset: SpiceCell) -> int: return libspice.ordi_c(item, ctypes.byref(inset)) +@spicelock_for_multithread @spice_error_check def orderc(array: Sequence[str], ndim: Optional[int] = None) -> ndarray: """ @@ -9328,6 +9687,7 @@ def orderc(array: Sequence[str], ndim: Optional[int] = None) -> ndarray: return stypes.c_vector_to_python(iorder) +@spicelock_for_multithread @spice_error_check def orderd(array: Sequence[float], ndim: Optional[int] = None) -> ndarray: """ @@ -9349,6 +9709,7 @@ def orderd(array: Sequence[float], ndim: Optional[int] = None) -> ndarray: return stypes.c_vector_to_python(iorder) +@spicelock_for_multithread @spice_error_check def orderi(array: Sequence[int], ndim: Optional[int] = None) -> ndarray: """ @@ -9370,6 +9731,7 @@ def orderi(array: Sequence[int], ndim: Optional[int] = None) -> ndarray: return stypes.c_vector_to_python(iorder) +@spicelock_for_multithread @spice_error_check def oscelt(state: ndarray, et: float, mu: Union[float, int]) -> ndarray: """ @@ -9416,6 +9778,7 @@ def oscltx(state: ndarray, et: float, mu: int) -> ndarray: ################################################################################ # P +@spicelock_for_multithread @spice_error_check def pckcls(handle: int) -> None: """ @@ -9429,6 +9792,7 @@ def pckcls(handle: int) -> None: libspice.pckcls_c(handle) +@spicelock_for_multithread @spice_error_check def pckcov(pck: str, idcode: int, cover: SpiceCell) -> None: """ @@ -9448,6 +9812,7 @@ def pckcov(pck: str, idcode: int, cover: SpiceCell) -> None: libspice.pckcov_c(pck, idcode, ctypes.byref(cover)) +@spicelock_for_multithread @spice_error_check def pckfrm(pck: str, ids: SpiceCell) -> None: """ @@ -9465,6 +9830,7 @@ def pckfrm(pck: str, ids: SpiceCell) -> None: libspice.pckfrm_c(pck, ctypes.byref(ids)) +@spicelock_for_multithread @spice_error_check def pcklof(filename: str) -> int: """ @@ -9483,6 +9849,7 @@ def pcklof(filename: str) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def pckopn(name: str, ifname: str, ncomch: int) -> int: """ @@ -9503,6 +9870,7 @@ def pckopn(name: str, ifname: str, ncomch: int) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def pckuof(handle: int) -> None: """ @@ -9517,6 +9885,7 @@ def pckuof(handle: int) -> None: libspice.pckuof_c(handle) +@spicelock_for_multithread @spice_error_check def pckw02( handle: int, @@ -9566,6 +9935,7 @@ def pckw02( ) +@spicelock_for_multithread @spice_error_check def pcpool(name: str, cvals: Sequence[str]) -> None: """ @@ -9585,6 +9955,7 @@ def pcpool(name: str, cvals: Sequence[str]) -> None: libspice.pcpool_c(name, n, lenvals, cvals) +@spicelock_for_multithread @spice_error_check def pdpool(name: str, dvals: Union[ndarray, Iterable[float]]) -> None: """ @@ -9603,6 +9974,7 @@ def pdpool(name: str, dvals: Union[ndarray, Iterable[float]]) -> None: libspice.pdpool_c(name, n, dvals) +@spicelock_for_multithread @spice_error_check def pgrrec(body: str, lon: float, lat: float, alt: int, re: float, f: float) -> ndarray: """ @@ -9629,6 +10001,7 @@ def pgrrec(body: str, lon: float, lat: float, alt: int, re: float, f: float) -> return stypes.c_vector_to_python(rectan) +@spicelock_for_multithread @spice_error_check def phaseq(et: float, target: str, illmn: str, obsrvr: str, abcorr: str) -> float: """ @@ -9652,6 +10025,7 @@ def phaseq(et: float, target: str, illmn: str, obsrvr: str, abcorr: str) -> floa return libspice.phaseq_c(et, target, illmn, obsrvr, abcorr) +@spicelock_for_multithread @spice_error_check def pi() -> float: """ @@ -9665,6 +10039,7 @@ def pi() -> float: return libspice.pi_c() +@spicelock_for_multithread @spice_error_check def pipool(name: str, ivals: ndarray) -> None: """ @@ -9682,6 +10057,7 @@ def pipool(name: str, ivals: ndarray) -> None: libspice.pipool_c(name, n, ivals) +@spicelock_for_multithread @spice_error_check def pjelpl(elin: Ellipse, plane: Plane) -> Ellipse: """ @@ -9700,6 +10076,7 @@ def pjelpl(elin: Ellipse, plane: Plane) -> Ellipse: return elout +@spicelock_for_multithread @spice_error_check def pl2nvc(plane: Plane) -> Tuple[ndarray, float]: """ @@ -9719,6 +10096,7 @@ def pl2nvc(plane: Plane) -> Tuple[ndarray, float]: return stypes.c_vector_to_python(normal), constant.value +@spicelock_for_multithread @spice_error_check def pl2nvp(plane: Plane) -> Tuple[ndarray, ndarray]: """ @@ -9737,6 +10115,7 @@ def pl2nvp(plane: Plane) -> Tuple[ndarray, ndarray]: return stypes.c_vector_to_python(normal), stypes.c_vector_to_python(point) +@spicelock_for_multithread @spice_error_check def pl2psv(plane: Plane) -> Tuple[ndarray, ndarray, ndarray]: """ @@ -9762,6 +10141,7 @@ def pl2psv(plane: Plane) -> Tuple[ndarray, ndarray, ndarray]: ) +@spicelock_for_multithread @spice_error_check def pltar(vrtces: Sequence[Iterable[float]], plates: Sequence[Iterable[int]]) -> float: """ @@ -9780,6 +10160,7 @@ def pltar(vrtces: Sequence[Iterable[float]], plates: Sequence[Iterable[int]]) -> return libspice.pltar_c(nv, vrtces, np, plates) +@spicelock_for_multithread @spice_error_check def pltexp( iverts: Iterable[Union[Iterable[Union[float, float]], Iterable[float]]], @@ -9803,6 +10184,7 @@ def pltexp( return stypes.c_matrix_to_numpy(overts) +@spicelock_for_multithread @spice_error_check def pltnp( point: Iterable[float], @@ -9831,6 +10213,7 @@ def pltnp( return stypes.c_vector_to_python(pnear), dist.value +@spicelock_for_multithread @spice_error_check def pltnrm( v1: Iterable[Union[float, float]], @@ -9856,6 +10239,7 @@ def pltnrm( return stypes.c_vector_to_python(normal) +@spicelock_for_multithread @spice_error_check def pltvol(vrtces: Sequence[Iterable[float]], plates: Sequence[Iterable[int]]) -> float: """ @@ -9875,6 +10259,7 @@ def pltvol(vrtces: Sequence[Iterable[float]], plates: Sequence[Iterable[int]]) - return libspice.pltvol_c(nv, vrtces, np, plates) +@spicelock_for_multithread @spice_error_check def polyds(coeffs: Iterable[float], deg: int, nderiv: int, t: int) -> ndarray: """ @@ -9898,6 +10283,7 @@ def polyds(coeffs: Iterable[float], deg: int, nderiv: int, t: int) -> ndarray: return stypes.c_vector_to_python(p) +@spicelock_for_multithread @spice_error_check def pos(string: str, substr: str, start: int) -> int: """ @@ -9919,6 +10305,7 @@ def pos(string: str, substr: str, start: int) -> int: return libspice.pos_c(string, substr, start) +@spicelock_for_multithread @spice_error_check def posr(string: str, substr: str, start: int) -> int: """ @@ -9944,6 +10331,7 @@ def posr(string: str, substr: str, start: int) -> int: # skip for no as this is not really an important function for python users +@spicelock_for_multithread @spice_error_check def prop2b(gm: float, pvinit: ndarray, dt: float) -> ndarray: """ @@ -9966,6 +10354,7 @@ def prop2b(gm: float, pvinit: ndarray, dt: float) -> ndarray: return stypes.c_vector_to_python(pvprop) +@spicelock_for_multithread @spice_error_check def prsdp(string: str) -> float: """ @@ -9982,6 +10371,7 @@ def prsdp(string: str) -> float: return dpval.value +@spicelock_for_multithread @spice_error_check def prsint(string: str) -> int: """ @@ -9998,6 +10388,7 @@ def prsint(string: str) -> int: return intval.value +@spicelock_for_multithread @spice_error_check def psv2pl(point: ndarray, span1: ndarray, span2: ndarray) -> Plane: """ @@ -10021,6 +10412,7 @@ def psv2pl(point: ndarray, span1: ndarray, span2: ndarray) -> Plane: # skip putcml, is this really needed for python users? +@spicelock_for_multithread @spice_error_check def pxform(fromstr: str, tostr: str, et: float) -> ndarray: """ @@ -10042,6 +10434,7 @@ def pxform(fromstr: str, tostr: str, et: float) -> ndarray: return stypes.c_matrix_to_numpy(rotatematrix) +@spicelock_for_multithread @spice_error_check def pxfrm2(frame_from: str, frame_to: str, etfrom: float, etto: float) -> ndarray: """ @@ -10070,6 +10463,7 @@ def pxfrm2(frame_from: str, frame_to: str, etfrom: float, etto: float) -> ndarra # Q +@spicelock_for_multithread @spice_error_check def q2m(q: ndarray) -> ndarray: """ @@ -10086,7 +10480,8 @@ def q2m(q: ndarray) -> ndarray: return stypes.c_matrix_to_numpy(mout) -# @spice_error_check +# @spicelock_for_multithread +@spice_error_check def qcktrc(tracelen: int = _default_len_out) -> str: """ Return a string containing a traceback. @@ -10102,6 +10497,7 @@ def qcktrc(tracelen: int = _default_len_out) -> str: return stypes.to_python_string(tracestr) +@spicelock_for_multithread @spice_error_check def qdq2av(q: ndarray, dq: Iterable[float]) -> ndarray: """ @@ -10121,6 +10517,7 @@ def qdq2av(q: ndarray, dq: Iterable[float]) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def qxq(q1: Union[ndarray, Iterable[float]], q2: Iterable[float]) -> ndarray: """ @@ -10143,6 +10540,7 @@ def qxq(q1: Union[ndarray, Iterable[float]], q2: Iterable[float]) -> ndarray: # R +@spicelock_for_multithread @spice_error_check def radrec(inrange: float, re: float, dec: float) -> ndarray: """ @@ -10164,6 +10562,7 @@ def radrec(inrange: float, re: float, dec: float) -> ndarray: return stypes.c_vector_to_python(rectan) +@spicelock_for_multithread @spice_error_check def rav2xf(rot: Iterable[Iterable[float]], av: Iterable[float]) -> ndarray: """ @@ -10184,6 +10583,7 @@ def rav2xf(rot: Iterable[Iterable[float]], av: Iterable[float]) -> ndarray: return stypes.c_matrix_to_numpy(xform) +@spicelock_for_multithread @spice_error_check def raxisa(matrix: ndarray) -> Tuple[ndarray, float]: """ @@ -10202,6 +10602,7 @@ def raxisa(matrix: ndarray) -> Tuple[ndarray, float]: return stypes.c_vector_to_python(axis), angle.value +@spicelock_for_multithread @spice_error_check def rdtext( file: str, lenout: int = _default_len_out @@ -10223,6 +10624,7 @@ def rdtext( return stypes.to_python_string(line), bool(eof.value) +@spicelock_for_multithread @spice_error_check def reccyl(rectan: Iterable[float]) -> Tuple[float, float, float]: """ @@ -10244,6 +10646,7 @@ def reccyl(rectan: Iterable[float]) -> Tuple[float, float, float]: return radius.value, lon.value, z.value +@spicelock_for_multithread @spice_error_check def recgeo(rectan: Iterable[float], re: float, f: float) -> Tuple[float, float, float]: """ @@ -10276,6 +10679,7 @@ def recgeo(rectan: Iterable[float], re: float, f: float) -> Tuple[float, float, return longitude.value, latitude.value, alt.value +@spicelock_for_multithread @spice_error_check def reclat(rectan: Union[ndarray, Iterable[float]]) -> Tuple[float, float, float]: """ @@ -10296,6 +10700,7 @@ def reclat(rectan: Union[ndarray, Iterable[float]]) -> Tuple[float, float, float return radius.value, longitude.value, latitude.value +@spicelock_for_multithread @spice_error_check def recpgr( body: str, rectan: Union[ndarray, Iterable[float]], re: float, f: float @@ -10327,6 +10732,7 @@ def recpgr( return lon.value, lat.value, alt.value +@spicelock_for_multithread @spice_error_check def recrad(rectan: Union[ndarray, Iterable[float]]) -> Tuple[float, float, float]: """ @@ -10350,6 +10756,7 @@ def recrad(rectan: Union[ndarray, Iterable[float]]) -> Tuple[float, float, float return outrange.value, ra.value, dec.value +@spicelock_for_multithread @spice_error_check def recsph(rectan: ndarray) -> Tuple[float, float, float]: """ @@ -10371,6 +10778,7 @@ def recsph(rectan: ndarray) -> Tuple[float, float, float]: return r.value, colat.value, lon.value +@spicelock_for_multithread @spice_error_check def removc(item: str, inset: SpiceCell) -> None: """ @@ -10387,6 +10795,7 @@ def removc(item: str, inset: SpiceCell) -> None: libspice.removc_c(item, ctypes.byref(inset)) +@spicelock_for_multithread @spice_error_check def removd(item: float, inset: SpiceCell) -> None: """ @@ -10403,6 +10812,7 @@ def removd(item: float, inset: SpiceCell) -> None: libspice.removd_c(item, ctypes.byref(inset)) +@spicelock_for_multithread @spice_error_check def removi(item: int, inset: SpiceCell) -> None: """ @@ -10419,6 +10829,7 @@ def removi(item: int, inset: SpiceCell) -> None: libspice.removi_c(item, ctypes.byref(inset)) +@spicelock_for_multithread @spice_error_check def reordc( iorder: Iterable[int], ndim: int, lenvals: int, array: Iterable[str] @@ -10443,6 +10854,7 @@ def reordc( return [stypes.to_python_string(x.value) for x in array] +@spicelock_for_multithread @spice_error_check def reordd(iorder: Iterable[int], ndim: int, array: Iterable[float]) -> ndarray: """ @@ -10463,6 +10875,7 @@ def reordd(iorder: Iterable[int], ndim: int, array: Iterable[float]) -> ndarray: return stypes.c_vector_to_python(array) +@spicelock_for_multithread @spice_error_check def reordi(iorder: Iterable[int], ndim: int, array: Iterable[int]) -> ndarray: """ @@ -10483,6 +10896,7 @@ def reordi(iorder: Iterable[int], ndim: int, array: Iterable[int]) -> ndarray: return stypes.c_vector_to_python(array) +@spicelock_for_multithread @spice_error_check def reordl(iorder: Iterable[int], ndim: int, array: Iterable[bool]) -> ndarray: """ @@ -10503,6 +10917,7 @@ def reordl(iorder: Iterable[int], ndim: int, array: Iterable[bool]) -> ndarray: return stypes.c_int_vector_to_bool_python(array) +@spicelock_for_multithread @spice_error_check def repmc(instr: str, marker: str, value: str, lenout: Optional[int] = None) -> str: """ @@ -10526,6 +10941,7 @@ def repmc(instr: str, marker: str, value: str, lenout: Optional[int] = None) -> return stypes.to_python_string(out) +@spicelock_for_multithread @spice_error_check def repmct( instr: str, marker: str, value: int, repcase: str, lenout: Optional[int] = None @@ -10554,6 +10970,7 @@ def repmct( return stypes.to_python_string(out) +@spicelock_for_multithread @spice_error_check def repmd(instr: str, marker: str, value: float, sigdig: int) -> str: """ @@ -10577,6 +10994,7 @@ def repmd(instr: str, marker: str, value: float, sigdig: int) -> str: return stypes.to_python_string(out) +@spicelock_for_multithread @spice_error_check def repmf( instr: str, @@ -10611,6 +11029,7 @@ def repmf( return stypes.to_python_string(out) +@spicelock_for_multithread @spice_error_check def repmi(instr: str, marker: str, value: int, lenout: Optional[int] = None) -> str: """ @@ -10634,6 +11053,7 @@ def repmi(instr: str, marker: str, value: int, lenout: Optional[int] = None) -> return stypes.to_python_string(out) +@spicelock_for_multithread @spice_error_check def repmot( instr: str, marker: str, value: int, repcase: str, lenout: Optional[int] = None @@ -10673,6 +11093,7 @@ def reset() -> None: libspice.reset_c() +@spicelock_for_multithread @spice_error_check def return_c() -> bool: """ @@ -10685,6 +11106,7 @@ def return_c() -> bool: return bool(libspice.return_c()) +@spicelock_for_multithread @spice_error_check def rotate(angle: float, iaxis: int) -> ndarray: """ @@ -10705,6 +11127,7 @@ def rotate(angle: float, iaxis: int) -> ndarray: return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def rotmat(m1: ndarray, angle: float, iaxis: int) -> ndarray: """ @@ -10727,6 +11150,7 @@ def rotmat(m1: ndarray, angle: float, iaxis: int) -> ndarray: return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def rotvec(v1: Iterable[Union[float, float]], angle: float, iaxis: int) -> ndarray: """ @@ -10749,6 +11173,7 @@ def rotvec(v1: Iterable[Union[float, float]], angle: float, iaxis: int) -> ndarr return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def rpd() -> float: """ @@ -10761,6 +11186,7 @@ def rpd() -> float: return libspice.rpd_c() +@spicelock_for_multithread @spice_error_check def rquad(a: float, b: float, c: float) -> Tuple[ndarray, ndarray]: """ @@ -10786,6 +11212,7 @@ def rquad(a: float, b: float, c: float) -> Tuple[ndarray, ndarray]: # S +@spicelock_for_multithread @spice_error_check def saelgv(vec1: Iterable[float], vec2: Iterable[float]) -> Tuple[ndarray, ndarray]: """ @@ -10806,6 +11233,7 @@ def saelgv(vec1: Iterable[float], vec2: Iterable[float]) -> Tuple[ndarray, ndarr return stypes.c_vector_to_python(smajor), stypes.c_vector_to_python(sminor) +@spicelock_for_multithread @spice_error_check def scard(incard: int, cell: SpiceCell) -> SpiceCell: """ @@ -10823,6 +11251,7 @@ def scard(incard: int, cell: SpiceCell) -> SpiceCell: return cell +@spicelock_for_multithread @spice_error_check def scdecd( sc: int, sclkdp: float, lenout: int = _default_len_out, mxpart: Optional[int] = None @@ -10848,6 +11277,7 @@ def scdecd( return stypes.to_python_string(sclkch) +@spicelock_for_multithread @spice_error_check def sce2c(sc: int, et: float) -> float: """ @@ -10870,6 +11300,7 @@ def sce2c(sc: int, et: float) -> float: return sclkdp.value +@spicelock_for_multithread @spice_error_check def sce2s(sc: int, et: float, lenout: int = _default_len_out) -> str: """ @@ -10891,6 +11322,7 @@ def sce2s(sc: int, et: float, lenout: int = _default_len_out) -> str: return stypes.to_python_string(sclkch) +@spicelock_for_multithread @spice_error_check def sce2t(sc: int, et: float) -> float: """ @@ -10912,6 +11344,7 @@ def sce2t(sc: int, et: float) -> float: return sclkdp.value +@spicelock_for_multithread @spice_error_check def scencd( sc: int, sclkch: Union[str, Iterable[str]], mxpart: Optional[int] = None @@ -10941,6 +11374,7 @@ def scencd( return sclkdp.value +@spicelock_for_multithread @spice_error_check def scfmt(sc: int, ticks: float, lenout: int = _default_len_out) -> str: """ @@ -10961,6 +11395,7 @@ def scfmt(sc: int, ticks: float, lenout: int = _default_len_out) -> str: return stypes.to_python_string(clkstr) +@spicelock_for_multithread @spice_error_check def scpart(sc: int) -> Tuple[ndarray, ndarray]: """ @@ -10986,6 +11421,7 @@ def scpart(sc: int) -> Tuple[ndarray, ndarray]: ) +@spicelock_for_multithread @spice_error_check def scs2e(sc: int, sclkch: str) -> float: """ @@ -11004,6 +11440,7 @@ def scs2e(sc: int, sclkch: str) -> float: return et.value +@spicelock_for_multithread @spice_error_check def sct2e(sc: int, sclkdp: Union[float, Iterable[float]]) -> Union[float, ndarray]: """ @@ -11031,6 +11468,7 @@ def sct2e(sc: int, sclkdp: Union[float, Iterable[float]]) -> Union[float, ndarra return et.value +@spicelock_for_multithread @spice_error_check def sctiks(sc: int, clkstr: str) -> float: """ @@ -11049,6 +11487,7 @@ def sctiks(sc: int, clkstr: str) -> float: return ticks.value +@spicelock_for_multithread @spice_error_check def sdiff(a: SpiceCell, b: SpiceCell) -> SpiceCell: """ @@ -11078,6 +11517,7 @@ def sdiff(a: SpiceCell, b: SpiceCell) -> SpiceCell: return c +@spicelock_for_multithread @spice_error_check def set_c(a: SpiceCell, op: str, b: SpiceCell) -> bool: """ @@ -11098,6 +11538,7 @@ def set_c(a: SpiceCell, op: str, b: SpiceCell) -> bool: return bool(libspice.set_c(ctypes.byref(a), op, ctypes.byref(b))) +@spicelock_for_multithread @spice_error_check def setmsg(message: str) -> None: """ @@ -11111,6 +11552,7 @@ def setmsg(message: str) -> None: libspice.setmsg_c(message) +@spicelock_for_multithread @spice_error_check def shellc(ndim: int, lenvals: int, array: Iterable[str]) -> Iterable[str]: # This works! looks like this is a mutable 2d char array @@ -11132,6 +11574,7 @@ def shellc(ndim: int, lenvals: int, array: Iterable[str]) -> Iterable[str]: return stypes.c_vector_to_python(array) +@spicelock_for_multithread @spice_error_check def shelld(ndim: int, array: Iterable[float]) -> ndarray: # Works!, use this as example for "I/O" parameters @@ -11150,6 +11593,7 @@ def shelld(ndim: int, array: Iterable[float]) -> ndarray: return stypes.c_vector_to_python(array) +@spicelock_for_multithread @spice_error_check def shelli(ndim: int, array: Iterable[int]) -> ndarray: # Works!, use this as example for "I/O" parameters @@ -11181,6 +11625,7 @@ def sigerr(message: str) -> None: libspice.sigerr_c(message) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def sincpt( @@ -11250,6 +11695,7 @@ def sincpt( ) +@spicelock_for_multithread @spice_error_check def size(cell: SpiceCell) -> int: """ @@ -11265,6 +11711,7 @@ def size(cell: SpiceCell) -> int: return libspice.size_c(ctypes.byref(cell)) +@spicelock_for_multithread @spice_error_check def spd() -> float: """ @@ -11277,6 +11724,7 @@ def spd() -> float: return libspice.spd_c() +@spicelock_for_multithread @spice_error_check def sphcyl(radius: float, colat: float, slon: float) -> Tuple[float, float, float]: """ @@ -11305,6 +11753,7 @@ def sphcyl(radius: float, colat: float, slon: float) -> Tuple[float, float, floa return r.value, lon.value, z.value +@spicelock_for_multithread @spice_error_check def sphlat(r: float, colat: float, lons: float) -> Tuple[float, float, float]: """ @@ -11332,6 +11781,7 @@ def sphlat(r: float, colat: float, lons: float) -> Tuple[float, float, float]: return radius.value, lon.value, lat.value +@spicelock_for_multithread @spice_error_check def sphrec(r: float, colat: float, lon: float) -> ndarray: """ @@ -11352,6 +11802,7 @@ def sphrec(r: float, colat: float, lon: float) -> ndarray: return stypes.c_vector_to_python(rectan) +@spicelock_for_multithread @spice_error_check def spkacs( targ: int, et: float, ref: str, abcorr: str, obs: int @@ -11388,6 +11839,7 @@ def spkacs( return stypes.c_vector_to_python(starg), lt.value, dlt.value +@spicelock_for_multithread @spice_error_check def spkapo( targ: int, et: float, ref: str, sobs: ndarray, abcorr: str @@ -11418,6 +11870,7 @@ def spkapo( return stypes.c_vector_to_python(ptarg), lt.value +@spicelock_for_multithread @spice_error_check def spkapp( targ: int, et: float, ref: str, sobs: ndarray, abcorr: str @@ -11452,6 +11905,7 @@ def spkapp( return stypes.c_vector_to_python(starg), lt.value +@spicelock_for_multithread @spice_error_check def spkaps( targ: int, @@ -11500,6 +11954,7 @@ def spkaps( return stypes.c_vector_to_python(starg), lt.value, dlt.value +@spicelock_for_multithread @spice_error_check def spk14a( handle: int, ncsets: int, coeffs: Iterable[float], epochs: Iterable[float] @@ -11522,6 +11977,7 @@ def spk14a( libspice.spk14a_c(handle, ncsets, coeffs, epochs) +@spicelock_for_multithread @spice_error_check def spk14b( handle: int, @@ -11559,6 +12015,7 @@ def spk14b( libspice.spk14b_c(handle, segid, body, center, framename, first, last, chbdeg) +@spicelock_for_multithread @spice_error_check def spk14e(handle: int) -> None: """ @@ -11573,6 +12030,7 @@ def spk14e(handle: int) -> None: libspice.spk14e_c(handle) +@spicelock_for_multithread @spice_error_check def spkcls(handle: int) -> None: """ @@ -11586,6 +12044,7 @@ def spkcls(handle: int) -> None: libspice.spkcls_c(handle) +@spicelock_for_multithread @spice_error_check def spkcov(spk: str, idcode: int, cover: Optional[SpiceCell] = None) -> SpiceCell: """ @@ -11609,6 +12068,7 @@ def spkcov(spk: str, idcode: int, cover: Optional[SpiceCell] = None) -> SpiceCel return cover +@spicelock_for_multithread @spice_error_check def spkcpo( target: str, @@ -11665,6 +12125,7 @@ def spkcpo( return stypes.c_vector_to_python(state), lt.value +@spicelock_for_multithread @spice_error_check def spkcpt( trgpos: Iterable[float], @@ -11721,6 +12182,7 @@ def spkcpt( return stypes.c_vector_to_python(state), lt.value +@spicelock_for_multithread @spice_error_check def spkcvo( target: str, @@ -11781,6 +12243,7 @@ def spkcvo( return stypes.c_vector_to_python(state), lt.value +@spicelock_for_multithread @spice_error_check def spkcvt( trgsta: Iterable[float], @@ -11841,6 +12304,7 @@ def spkcvt( return stypes.c_vector_to_python(state), lt.value +@spicelock_for_multithread @spice_error_check def spkez( targ: int, et: float, ref: str, abcorr: str, obs: int @@ -11872,6 +12336,7 @@ def spkez( return stypes.c_vector_to_python(starg), lt.value +@spicelock_for_multithread @spice_error_check def spkezp( targ: int, et: float, ref: str, abcorr: str, obs: int @@ -11903,6 +12368,7 @@ def spkezp( return stypes.c_vector_to_python(ptarg), lt.value +@spicelock_for_multithread @spice_error_check def spkezr( targ: str, et: Union[ndarray, float], ref: str, abcorr: str, obs: str @@ -11947,6 +12413,7 @@ def spkezr( return stypes.c_vector_to_python(starg), lt.value +@spicelock_for_multithread @spice_error_check def spkgeo(targ: int, et: float, ref: str, obs: int) -> Tuple[ndarray, float]: """ @@ -11971,6 +12438,7 @@ def spkgeo(targ: int, et: float, ref: str, obs: int) -> Tuple[ndarray, float]: return stypes.c_vector_to_python(state), lt.value +@spicelock_for_multithread @spice_error_check def spkgps(targ: int, et: float, ref: str, obs: int) -> Tuple[ndarray, float]: """ @@ -11995,6 +12463,7 @@ def spkgps(targ: int, et: float, ref: str, obs: int) -> Tuple[ndarray, float]: return stypes.c_vector_to_python(position), lt.value +@spicelock_for_multithread @spice_error_check def spklef(filename: str) -> int: """ @@ -12012,6 +12481,7 @@ def spklef(filename: str) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def spkltc( targ: int, et: float, ref: str, abcorr: str, stobs: ndarray @@ -12047,6 +12517,7 @@ def spkltc( return stypes.c_vector_to_python(starg), lt.value, dlt.value +@spicelock_for_multithread @spice_error_check def spkobj(spk: str, out_cell: Optional[SpiceCell] = None) -> SpiceCell: """ @@ -12066,6 +12537,7 @@ def spkobj(spk: str, out_cell: Optional[SpiceCell] = None) -> SpiceCell: return out_cell +@spicelock_for_multithread @spice_error_check def spkopa(filename: str) -> int: """ @@ -12082,6 +12554,7 @@ def spkopa(filename: str) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def spkopn(filename: str, ifname: str, ncomch: int) -> int: """ @@ -12102,6 +12575,7 @@ def spkopn(filename: str, ifname: str, ncomch: int) -> int: return handle.value +@spicelock_for_multithread @spice_error_check def spkpds( body: int, center: int, framestr: str, typenum: int, first: float, last: float @@ -12131,6 +12605,7 @@ def spkpds( return stypes.c_vector_to_python(descr) +@spicelock_for_multithread @spice_error_check def spkpos( targ: str, et: Union[float, ndarray], ref: str, abcorr: str, obs: str @@ -12171,6 +12646,7 @@ def spkpos( return stypes.c_vector_to_python(ptarg), lt.value +@spicelock_for_multithread @spice_error_check def spkpvn(handle: int, descr: ndarray, et: float) -> Tuple[int, ndarray, int]: """ @@ -12198,6 +12674,7 @@ def spkpvn(handle: int, descr: ndarray, et: float) -> Tuple[int, ndarray, int]: return ref.value, stypes.c_vector_to_python(state), center.value +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def spksfs(body: int, et: float, idlen: int) -> Tuple[int, ndarray, str, bool]: @@ -12235,6 +12712,7 @@ def spksfs(body: int, et: float, idlen: int) -> Tuple[int, ndarray, str, bool]: ) +@spicelock_for_multithread @spice_error_check def spkssb(targ: int, et: float, ref: str) -> ndarray: """ @@ -12256,6 +12734,7 @@ def spkssb(targ: int, et: float, ref: str) -> ndarray: return stypes.c_vector_to_python(starg) +@spicelock_for_multithread @spice_error_check def spksub( handle: int, descr: ndarray, identin: str, begin: float, end: float, newh: int @@ -12283,6 +12762,7 @@ def spksub( libspice.spksub_c(handle, descr, identin, begin, end, newh) +@spicelock_for_multithread @spice_error_check def spkuds(descr: ndarray) -> Tuple[int, int, int, int, float, float, int, int]: """ @@ -12334,6 +12814,7 @@ def spkuds(descr: ndarray) -> Tuple[int, int, int, int, float, float, int, int]: ) +@spicelock_for_multithread @spice_error_check def spkuef(handle: int) -> None: """ @@ -12348,6 +12829,7 @@ def spkuef(handle: int) -> None: libspice.spkuef_c(handle) +@spicelock_for_multithread @spice_error_check def spkw02( handle: int, @@ -12409,6 +12891,7 @@ def spkw02( ) +@spicelock_for_multithread @spice_error_check def spkw03( handle: int, @@ -12470,6 +12953,7 @@ def spkw03( ) +@spicelock_for_multithread @spice_error_check def spkw05( handle: int, @@ -12520,6 +13004,7 @@ def spkw05( ) +@spicelock_for_multithread @spice_error_check def spkw08( handle: int, @@ -12582,6 +13067,7 @@ def spkw08( ) +@spicelock_for_multithread @spice_error_check def spkw09( handle: int, @@ -12629,6 +13115,7 @@ def spkw09( ) +@spicelock_for_multithread @spice_error_check def spkw10( handle: int, @@ -12677,6 +13164,7 @@ def spkw10( ) +@spicelock_for_multithread @spice_error_check def spkw12( handle: int, @@ -12738,6 +13226,7 @@ def spkw12( ) +@spicelock_for_multithread @spice_error_check def spkw13( handle: int, @@ -12785,6 +13274,7 @@ def spkw13( ) +@spicelock_for_multithread @spice_error_check def spkw15( handle: int, @@ -12866,6 +13356,7 @@ def spkw15( ) +@spicelock_for_multithread @spice_error_check def spkw17( handle: int, @@ -12913,6 +13404,7 @@ def spkw17( ) +@spicelock_for_multithread @spice_error_check def spkw18( handle: int, @@ -12972,6 +13464,7 @@ def spkw18( ) +@spicelock_for_multithread @spice_error_check def spkw20( handle: int, @@ -13045,6 +13538,7 @@ def spkw20( ) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def srfc2s(code: int, bodyid: int, srflen: int = _default_len_out) -> Tuple[str, bool]: @@ -13072,6 +13566,7 @@ def srfc2s(code: int, bodyid: int, srflen: int = _default_len_out) -> Tuple[str, return stypes.to_python_string(srfstr), bool(isname.value) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def srfcss(code: int, bodstr: str, srflen: int = _default_len_out) -> Tuple[str, bool]: @@ -13097,6 +13592,7 @@ def srfcss(code: int, bodstr: str, srflen: int = _default_len_out) -> Tuple[str, return stypes.to_python_string(srfstr), bool(isname.value) +@spicelock_for_multithread @spice_error_check def srfnrm( method: str, target: str, et: float, fixref: str, srfpts: ndarray @@ -13128,6 +13624,7 @@ def srfnrm( return stypes.c_matrix_to_numpy(normls) +@spicelock_for_multithread @spice_error_check def srfrec(body: int, longitude: float, latitude: float) -> ndarray: """ @@ -13149,6 +13646,7 @@ def srfrec(body: int, longitude: float, latitude: float) -> ndarray: return stypes.c_vector_to_python(rectan) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def srfs2c(srfstr: str, bodstr: str) -> Tuple[int, bool]: @@ -13171,6 +13669,7 @@ def srfs2c(srfstr: str, bodstr: str) -> Tuple[int, bool]: return code.value, bool(isname.value) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def srfscc(srfstr: str, bodyid: int) -> Tuple[int, bool]: @@ -13193,6 +13692,7 @@ def srfscc(srfstr: str, bodyid: int) -> Tuple[int, bool]: return code.value, bool(isname.value) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def srfxpt( @@ -13301,6 +13801,7 @@ def srfxpt( ) +@spicelock_for_multithread @spice_error_check def ssize(newsize: int, cell: SpiceCell) -> SpiceCell: """ @@ -13318,6 +13819,7 @@ def ssize(newsize: int, cell: SpiceCell) -> SpiceCell: return cell +@spicelock_for_multithread @spice_error_check def stelab(pobj: ndarray, vobs: ndarray) -> ndarray: """ @@ -13341,6 +13843,7 @@ def stelab(pobj: ndarray, vobs: ndarray) -> ndarray: return stypes.c_vector_to_python(appobj) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def stpool( @@ -13374,6 +13877,7 @@ def stpool( return stypes.to_python_string(strout), sizet.value, bool(found.value) +@spicelock_for_multithread @spice_error_check def str2et(time: Union[str, Iterable[str]]) -> Union[float, ndarray]: """ @@ -13400,6 +13904,7 @@ def str2et(time: Union[str, Iterable[str]]) -> Union[float, ndarray]: return et.value +@spicelock_for_multithread @spice_error_check def datetime2et(dt: Union[Iterable[datetime], datetime]) -> Union[ndarray, float]: """ @@ -13447,6 +13952,7 @@ def fromisoformat(s): return datetime.strptime(s, "%Y-%m-%dT%H:%M:%S.%f").replace(tzinfo=timezone.utc) +@spicelock_for_multithread @spice_error_check def et2datetime(et: Union[Iterable[float], float]) -> Union[ndarray, datetime]: """ @@ -13465,6 +13971,7 @@ def et2datetime(et: Union[Iterable[float], float]) -> Union[ndarray, datetime]: return fromisoformat(result) +@spicelock_for_multithread @spice_error_check def subpnt( method: str, target: str, et: float, fixref: str, abcorr: str, obsrvr: str @@ -13508,6 +14015,7 @@ def subpnt( ) +@spicelock_for_multithread @spice_error_check def subpt( method: str, @@ -13568,6 +14076,7 @@ def subpt( return stypes.c_vector_to_python(spoint), alt.value +@spicelock_for_multithread @spice_error_check def subslr( method: str, target: str, et: float, fixref: str, abcorr: str, obsrvr: str @@ -13611,6 +14120,7 @@ def subslr( ) +@spicelock_for_multithread @spice_error_check def subsol(method: str, target: str, et: float, abcorr: str, obsrvr: str) -> ndarray: """ @@ -13642,6 +14152,7 @@ def subsol(method: str, target: str, et: float, abcorr: str, obsrvr: str) -> nda return stypes.c_vector_to_python(spoint) +@spicelock_for_multithread @spice_error_check def sumad(array: Sequence[float]) -> float: """ @@ -13657,6 +14168,7 @@ def sumad(array: Sequence[float]) -> float: return libspice.sumad_c(array, n) +@spicelock_for_multithread @spice_error_check def sumai(array: Sequence[int]) -> int: """ @@ -13672,6 +14184,7 @@ def sumai(array: Sequence[int]) -> int: return libspice.sumai_c(array, n) +@spicelock_for_multithread @spice_error_check def surfnm(a: float, b: float, c: float, point: Iterable[float]) -> ndarray: """ @@ -13695,6 +14208,7 @@ def surfnm(a: float, b: float, c: float, point: Iterable[float]) -> ndarray: return stypes.c_vector_to_python(normal) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def surfpt( @@ -13728,6 +14242,7 @@ def surfpt( return stypes.c_vector_to_python(point), bool(found.value) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def surfpv( @@ -13757,6 +14272,7 @@ def surfpv( return stypes.c_vector_to_python(stx), bool(found.value) +@spicelock_for_multithread @spice_error_check def swpool(agent: str, nnames: int, lenvals: int, names: Iterable[str]) -> None: """ @@ -13777,6 +14293,7 @@ def swpool(agent: str, nnames: int, lenvals: int, names: Iterable[str]) -> None: libspice.swpool_c(agent, nnames, lenvals, names) +@spicelock_for_multithread @spice_error_check def sxform(instring: str, tostring: str, et: Union[float, ndarray]) -> ndarray: """ @@ -13807,6 +14324,7 @@ def sxform(instring: str, tostring: str, et: Union[float, ndarray]) -> ndarray: return stypes.c_matrix_to_numpy(xform) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def szpool(name: str) -> Tuple[int, bool]: @@ -13829,6 +14347,7 @@ def szpool(name: str) -> Tuple[int, bool]: # T +@spicelock_for_multithread @spice_error_check def termpt( method: str, @@ -13928,6 +14447,7 @@ def termpt( ) +@spicelock_for_multithread @spice_error_check def timdef(action: str, item: str, lenout: int, value: Optional[str] = None) -> str: """ @@ -13952,6 +14472,7 @@ def timdef(action: str, item: str, lenout: int, value: Optional[str] = None) -> return stypes.to_python_string(value) +@spicelock_for_multithread @spice_error_check def timout( et: Union[ndarray, float], pictur: str, lenout: int = _default_len_out @@ -13984,6 +14505,7 @@ def timout( return stypes.to_python_string(output) +@spicelock_for_multithread @spice_error_check def tipbod(ref: str, body: int, et: float) -> ndarray: """ @@ -14006,6 +14528,7 @@ def tipbod(ref: str, body: int, et: float) -> ndarray: return stypes.c_matrix_to_numpy(retmatrix) +@spicelock_for_multithread @spice_error_check def tisbod(ref: str, body: int, et: float) -> ndarray: """ @@ -14027,6 +14550,7 @@ def tisbod(ref: str, body: int, et: float) -> ndarray: return stypes.c_matrix_to_numpy(retmatrix) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def tkfram(typid: int) -> Tuple[ndarray, int, bool]: @@ -14049,7 +14573,8 @@ def tkfram(typid: int) -> Tuple[ndarray, int, bool]: return stypes.c_matrix_to_numpy(matrix), next_frame.value, bool(found.value) -# @spice_error_check +# @spicelock_for_multithread +@spice_error_check def tkvrsn(item: str) -> str: """ Given an item such as the Toolkit or an entry point name, return @@ -14064,6 +14589,7 @@ def tkvrsn(item: str) -> str: return stypes.to_python_string(libspice.tkvrsn_c(item)) +@spicelock_for_multithread @spice_error_check def tparse(instring: str, lenout: int = _default_len_out) -> Tuple[float, str]: """ @@ -14084,6 +14610,7 @@ def tparse(instring: str, lenout: int = _default_len_out) -> Tuple[float, str]: return sp2000.value, stypes.to_python_string(errmsg) +@spicelock_for_multithread @spice_error_check def tpictr( sample: str, lenout: int = _default_len_out, lenerr: int = _default_len_out @@ -14112,6 +14639,7 @@ def tpictr( return stypes.to_python_string(pictur), ok.value, stypes.to_python_string(errmsg) +@spicelock_for_multithread @spice_error_check def trace(matrix: Iterable[Iterable[float]]) -> float: """ @@ -14126,6 +14654,7 @@ def trace(matrix: Iterable[Iterable[float]]) -> float: return libspice.trace_c(matrix) +@spicelock_for_multithread @spice_error_check def trcdep() -> int: """ @@ -14140,6 +14669,7 @@ def trcdep() -> int: return depth.value +@spicelock_for_multithread @spice_error_check def trcnam(index: int, namlen: int = _default_len_out) -> str: """ @@ -14160,6 +14690,7 @@ def trcnam(index: int, namlen: int = _default_len_out) -> str: return stypes.to_python_string(name) +@spicelock_for_multithread @spice_error_check def trcoff() -> None: """ @@ -14171,6 +14702,7 @@ def trcoff() -> None: libspice.trcoff_c() +@spicelock_for_multithread @spice_error_check def tsetyr(year: int) -> None: """ @@ -14186,6 +14718,7 @@ def tsetyr(year: int) -> None: libspice.tsetyr_c(year) +@spicelock_for_multithread @spice_error_check def twopi() -> float: """ @@ -14199,6 +14732,7 @@ def twopi() -> float: return libspice.twopi_c() +@spicelock_for_multithread @spice_error_check def twovec( axdef: Iterable[float], indexa: int, plndef: Iterable[float], indexp: int @@ -14225,6 +14759,7 @@ def twovec( return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def txtopn(fname: str) -> int: """ @@ -14244,6 +14779,7 @@ def txtopn(fname: str) -> int: return unit_out.value +@spicelock_for_multithread @spice_error_check def tyear() -> float: """ @@ -14260,6 +14796,7 @@ def tyear() -> float: # U +@spicelock_for_multithread @spice_error_check def ucase(inchar: str, lenout: Optional[int] = None) -> str: """ @@ -14280,6 +14817,7 @@ def ucase(inchar: str, lenout: Optional[int] = None) -> str: return stypes.to_python_string(outchar) +@spicelock_for_multithread @spice_error_check def ucrss(v1: ndarray, v2: ndarray) -> ndarray: """ @@ -14333,6 +14871,7 @@ def udfunc(et_in): return bool(isdescr.value) +@spicelock_for_multithread @spice_error_check def uddf(udfunc: UDFUNC, x: float, dx: float) -> float: """ @@ -14380,6 +14919,7 @@ def udf(x: float) -> float: return value.value +@spicelock_for_multithread @spice_error_check def union(a: SpiceCell, b: SpiceCell) -> SpiceCell: """ @@ -14408,6 +14948,7 @@ def union(a: SpiceCell, b: SpiceCell) -> SpiceCell: return c +@spicelock_for_multithread @spice_error_check def unitim(epoch: float, insys: str, outsys: str) -> float: """ @@ -14429,6 +14970,7 @@ def unitim(epoch: float, insys: str, outsys: str) -> float: return libspice.unitim_c(epoch, insys, outsys) +@spicelock_for_multithread @spice_error_check def unload(filename: Union[str, Iterable[str]]) -> None: """ @@ -14446,6 +14988,7 @@ def unload(filename: Union[str, Iterable[str]]) -> None: libspice.unload_c(filename) +@spicelock_for_multithread @spice_error_check def unorm(v1: ndarray) -> Tuple[ndarray, float]: """ @@ -14463,6 +15006,7 @@ def unorm(v1: ndarray) -> Tuple[ndarray, float]: return stypes.c_vector_to_python(vout), vmag.value +@spicelock_for_multithread @spice_error_check def unormg(v1: ndarray, ndim: int) -> Tuple[ndarray, float]: """ @@ -14483,6 +15027,7 @@ def unormg(v1: ndarray, ndim: int) -> Tuple[ndarray, float]: return stypes.c_vector_to_python(vout), vmag.value +@spicelock_for_multithread @spice_error_check def utc2et(utcstr: str) -> float: """ @@ -14504,6 +15049,7 @@ def utc2et(utcstr: str) -> float: # V +@spicelock_for_multithread @spice_error_check def vadd(v1: Iterable[float], v2: Iterable[float]) -> ndarray: """Add two 3 dimensional vectors. @@ -14520,6 +15066,7 @@ def vadd(v1: Iterable[float], v2: Iterable[float]) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vaddg(v1: Iterable[float], v2: Iterable[float], ndim: int) -> ndarray: """ @@ -14539,6 +15086,7 @@ def vaddg(v1: Iterable[float], v2: Iterable[float], ndim: int) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def valid(insize: int, n: int, inset: SpiceCell) -> SpiceCell: """ @@ -14558,6 +15106,7 @@ def valid(insize: int, n: int, inset: SpiceCell) -> SpiceCell: return inset +@spicelock_for_multithread @spice_error_check def vcrss(v1: ndarray, v2: ndarray) -> ndarray: """ @@ -14576,6 +15125,7 @@ def vcrss(v1: ndarray, v2: ndarray) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vdist(v1: ndarray, v2: ndarray) -> float: """ @@ -14592,6 +15142,7 @@ def vdist(v1: ndarray, v2: ndarray) -> float: return libspice.vdist_c(v1, v2) +@spicelock_for_multithread @spice_error_check def vdistg(v1: ndarray, v2: ndarray, ndim: int) -> float: """ @@ -14610,6 +15161,7 @@ def vdistg(v1: ndarray, v2: ndarray, ndim: int) -> float: return libspice.vdistg_c(v1, v2, ndim) +@spicelock_for_multithread @spice_error_check def vdot(v1: ndarray, v2: ndarray) -> float: """ @@ -14626,6 +15178,7 @@ def vdot(v1: ndarray, v2: ndarray) -> float: return libspice.vdot_c(v1, v2) +@spicelock_for_multithread @spice_error_check def vdotg(v1: ndarray, v2: ndarray, ndim: int) -> float: """ @@ -14645,6 +15198,7 @@ def vdotg(v1: ndarray, v2: ndarray, ndim: int) -> float: return libspice.vdotg_c(v1, v2, ndim) +@spicelock_for_multithread @spice_error_check def vequ(v1: ndarray) -> ndarray: """ @@ -14661,6 +15215,7 @@ def vequ(v1: ndarray) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vequg(v1: ndarray, ndim: int) -> ndarray: """ @@ -14679,6 +15234,7 @@ def vequg(v1: ndarray, ndim: int) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vhat(v1: ndarray) -> ndarray: """ @@ -14695,6 +15251,7 @@ def vhat(v1: ndarray) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vhatg(v1: ndarray, ndim: int) -> ndarray: """ @@ -14713,6 +15270,7 @@ def vhatg(v1: ndarray, ndim: int) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vlcom( a: float, @@ -14741,6 +15299,7 @@ def vlcom( return stypes.c_vector_to_python(sumv) +@spicelock_for_multithread @spice_error_check def vlcom3( a: float, @@ -14775,6 +15334,7 @@ def vlcom3( return stypes.c_vector_to_python(sumv) +@spicelock_for_multithread @spice_error_check def vlcomg( n: int, @@ -14806,6 +15366,7 @@ def vlcomg( return stypes.c_vector_to_python(sumv) +@spicelock_for_multithread @spice_error_check def vminug(vin: ndarray, ndim: int) -> ndarray: """ @@ -14824,6 +15385,7 @@ def vminug(vin: ndarray, ndim: int) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vminus(vin: ndarray) -> ndarray: """ @@ -14840,6 +15402,7 @@ def vminus(vin: ndarray) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vnorm(v: ndarray) -> float: """ @@ -14854,6 +15417,7 @@ def vnorm(v: ndarray) -> float: return libspice.vnorm_c(v) +@spicelock_for_multithread @spice_error_check def vnormg(v: ndarray, ndim: int) -> float: """ @@ -14870,6 +15434,7 @@ def vnormg(v: ndarray, ndim: int) -> float: return libspice.vnormg_c(v, ndim) +@spicelock_for_multithread @spice_error_check def vpack(x: float, y: float, z: float) -> ndarray: """ @@ -14890,6 +15455,7 @@ def vpack(x: float, y: float, z: float) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vperp(a: ndarray, b: ndarray) -> ndarray: """ @@ -14909,6 +15475,7 @@ def vperp(a: ndarray, b: ndarray) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vprjp(vin: Iterable[float], plane: Plane) -> ndarray: """ @@ -14926,6 +15493,7 @@ def vprjp(vin: Iterable[float], plane: Plane) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check @spice_found_exception_thrower def vprjpi(vin: Iterable[float], projpl: Plane, invpl: Plane) -> Tuple[ndarray, bool]: @@ -14949,6 +15517,7 @@ def vprjpi(vin: Iterable[float], projpl: Plane, invpl: Plane) -> Tuple[ndarray, return stypes.c_vector_to_python(vout), bool(found.value) +@spicelock_for_multithread @spice_error_check def vproj(a: ndarray, b: ndarray) -> ndarray: """ @@ -14967,6 +15536,7 @@ def vproj(a: ndarray, b: ndarray) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vrel(v1: Iterable[float], v2: Iterable[float]) -> float: """ @@ -14983,6 +15553,7 @@ def vrel(v1: Iterable[float], v2: Iterable[float]) -> float: return libspice.vrel_c(v1, v2) +@spicelock_for_multithread @spice_error_check def vrelg(v1: Iterable[float], v2: Iterable[float], ndim: int) -> float: """ @@ -15001,6 +15572,7 @@ def vrelg(v1: Iterable[float], v2: Iterable[float], ndim: int) -> float: return libspice.vrelg_c(v1, v2, ndim) +@spicelock_for_multithread @spice_error_check def vrotv(v: ndarray, axis: ndarray, theta: float) -> ndarray: """ @@ -15022,6 +15594,7 @@ def vrotv(v: ndarray, axis: ndarray, theta: float) -> ndarray: return stypes.c_vector_to_python(r) +@spicelock_for_multithread @spice_error_check def vscl(s: float, v1: ndarray) -> ndarray: """ @@ -15040,6 +15613,7 @@ def vscl(s: float, v1: ndarray) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vsclg(s: float, v1: ndarray, ndim: int) -> ndarray: """ @@ -15060,6 +15634,7 @@ def vsclg(s: float, v1: ndarray, ndim: int) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vsep(v1: ndarray, v2: ndarray) -> float: """ @@ -15078,6 +15653,7 @@ def vsep(v1: ndarray, v2: ndarray) -> float: return libspice.vsep_c(v1, v2) +@spicelock_for_multithread @spice_error_check def vsepg(v1: ndarray, v2: ndarray, ndim: int) -> float: """ @@ -15098,6 +15674,7 @@ def vsepg(v1: ndarray, v2: ndarray, ndim: int) -> float: return libspice.vsepg_c(v1, v2, ndim) +@spicelock_for_multithread @spice_error_check def vsub(v1: ndarray, v2: ndarray) -> ndarray: """ @@ -15117,6 +15694,7 @@ def vsub(v1: ndarray, v2: ndarray) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vsubg(v1: ndarray, v2: ndarray, ndim: int) -> ndarray: """ @@ -15138,6 +15716,7 @@ def vsubg(v1: ndarray, v2: ndarray, ndim: int) -> ndarray: return stypes.c_vector_to_python(vout) +@spicelock_for_multithread @spice_error_check def vtmv(v1: ndarray, matrix: ndarray, v2: ndarray) -> float: """ @@ -15157,6 +15736,7 @@ def vtmv(v1: ndarray, matrix: ndarray, v2: ndarray) -> float: return libspice.vtmv_c(v1, matrix, v2) +@spicelock_for_multithread @spice_error_check def vtmvg(v1: ndarray, matrix: ndarray, v2: ndarray, nrow: int, ncol: int) -> float: """ @@ -15181,6 +15761,7 @@ def vtmvg(v1: ndarray, matrix: ndarray, v2: ndarray, nrow: int, ncol: int) -> fl return libspice.vtmvg_c(v1, matrix, v2, nrow, ncol) +@spicelock_for_multithread @spice_error_check def vupack(v: ndarray) -> Tuple[float, float, float]: """ @@ -15199,6 +15780,7 @@ def vupack(v: ndarray) -> Tuple[float, float, float]: return x.value, y.value, z.value +@spicelock_for_multithread @spice_error_check def vzero(v: ndarray) -> bool: """ @@ -15213,6 +15795,7 @@ def vzero(v: ndarray) -> bool: return bool(libspice.vzero_c(v)) +@spicelock_for_multithread @spice_error_check def vzerog(v: ndarray, ndim: int) -> bool: """ @@ -15233,6 +15816,7 @@ def vzerog(v: ndarray, ndim: int) -> bool: # W +@spicelock_for_multithread @spice_error_check def wncard(window: SpiceCell) -> int: """ @@ -15248,6 +15832,7 @@ def wncard(window: SpiceCell) -> int: return libspice.wncard_c(window) +@spicelock_for_multithread @spice_error_check def wncomd(left: float, right: float, window: SpiceCell) -> SpiceCell: """ @@ -15270,6 +15855,7 @@ def wncomd(left: float, right: float, window: SpiceCell) -> SpiceCell: return result +@spicelock_for_multithread @spice_error_check def wncond(left: float, right: float, window: SpiceCell) -> SpiceCell: """ @@ -15290,6 +15876,7 @@ def wncond(left: float, right: float, window: SpiceCell) -> SpiceCell: return window +@spicelock_for_multithread @spice_error_check def wndifd(a: SpiceCell, b: SpiceCell) -> SpiceCell: """ @@ -15311,6 +15898,7 @@ def wndifd(a: SpiceCell, b: SpiceCell) -> SpiceCell: return c +@spicelock_for_multithread @spice_error_check def wnelmd(point: float, window: SpiceCell) -> bool: """ @@ -15329,6 +15917,7 @@ def wnelmd(point: float, window: SpiceCell) -> bool: return bool(libspice.wnelmd_c(point, ctypes.byref(window))) +@spicelock_for_multithread @spice_error_check def wnexpd(left: float, right: float, window: SpiceCell) -> SpiceCell: """ @@ -15349,6 +15938,7 @@ def wnexpd(left: float, right: float, window: SpiceCell) -> SpiceCell: return window +@spicelock_for_multithread @spice_error_check def wnextd(side: str, window: SpiceCell) -> SpiceCell: """ @@ -15369,6 +15959,7 @@ def wnextd(side: str, window: SpiceCell) -> SpiceCell: return window +@spicelock_for_multithread @spice_error_check def wnfetd(window: SpiceCell, n: int) -> Tuple[float, float]: """ @@ -15389,6 +15980,7 @@ def wnfetd(window: SpiceCell, n: int) -> Tuple[float, float]: return left.value, right.value +@spicelock_for_multithread @spice_error_check def wnfild(small: float, window: SpiceCell) -> SpiceCell: """ @@ -15407,6 +15999,7 @@ def wnfild(small: float, window: SpiceCell) -> SpiceCell: return window +@spicelock_for_multithread @spice_error_check def wnfltd(small: float, window: SpiceCell) -> SpiceCell: """ @@ -15425,6 +16018,7 @@ def wnfltd(small: float, window: SpiceCell) -> SpiceCell: return window +@spicelock_for_multithread @spice_error_check def wnincd(left: float, right: float, window: SpiceCell) -> bool: """ @@ -15444,6 +16038,7 @@ def wnincd(left: float, right: float, window: SpiceCell) -> bool: return bool(libspice.wnincd_c(left, right, ctypes.byref(window))) +@spicelock_for_multithread @spice_error_check def wninsd(left: float, right: float, window: SpiceCell) -> None: """ @@ -15462,6 +16057,7 @@ def wninsd(left: float, right: float, window: SpiceCell) -> None: libspice.wninsd_c(left, right, ctypes.byref(window)) +@spicelock_for_multithread @spice_error_check def wnintd(a: SpiceCell, b: SpiceCell) -> SpiceCell: """ @@ -15484,6 +16080,7 @@ def wnintd(a: SpiceCell, b: SpiceCell) -> SpiceCell: return c +@spicelock_for_multithread @spice_error_check def wnreld(a: SpiceCell, op: str, b: SpiceCell) -> bool: """ @@ -15505,6 +16102,7 @@ def wnreld(a: SpiceCell, op: str, b: SpiceCell) -> bool: return bool(libspice.wnreld_c(ctypes.byref(a), op, ctypes.byref(b))) +@spicelock_for_multithread @spice_error_check def wnsumd(window: SpiceCell) -> Tuple[float, float, float, int, int]: """ @@ -15537,6 +16135,7 @@ def wnsumd(window: SpiceCell) -> Tuple[float, float, float, int, int]: return meas.value, avg.value, stddev.value, shortest.value, longest.value +@spicelock_for_multithread @spice_error_check def wnunid(a: SpiceCell, b: SpiceCell) -> SpiceCell: """ @@ -15557,6 +16156,7 @@ def wnunid(a: SpiceCell, b: SpiceCell) -> SpiceCell: return c +@spicelock_for_multithread @spice_error_check def wnvald(insize: int, n: int, window: SpiceCell) -> SpiceCell: """ @@ -15578,6 +16178,7 @@ def wnvald(insize: int, n: int, window: SpiceCell) -> SpiceCell: return window +@spicelock_for_multithread @spice_error_check def writln(line: str, unit: int) -> None: """ @@ -15615,6 +16216,7 @@ def writln(line: str, unit: int) -> None: # X +@spicelock_for_multithread @spice_error_check def xf2eul(xform: ndarray, axisa: int, axisb: int, axisc: int) -> Tuple[ndarray, int]: """ @@ -15643,6 +16245,7 @@ def xf2eul(xform: ndarray, axisa: int, axisb: int, axisc: int) -> Tuple[ndarray, return stypes.c_vector_to_python(eulang), unique.value +@spicelock_for_multithread @spice_error_check def xf2rav(xform: ndarray) -> Tuple[ndarray, ndarray]: """ @@ -15663,6 +16266,7 @@ def xf2rav(xform: ndarray) -> Tuple[ndarray, ndarray]: return stypes.c_matrix_to_numpy(rot), stypes.c_vector_to_python(av) +@spicelock_for_multithread @spice_error_check def xfmsta( input_state: ndarray, input_coord_sys: str, output_coord_sys: str, body: str @@ -15691,6 +16295,7 @@ def xfmsta( return stypes.c_vector_to_python(output_state) +@spicelock_for_multithread @spice_error_check def xpose(m: Union[ndarray, Iterable[Iterable[float]]]) -> ndarray: """ @@ -15707,6 +16312,7 @@ def xpose(m: Union[ndarray, Iterable[Iterable[float]]]) -> ndarray: return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def xpose6(m: Iterable[Iterable[float]]) -> ndarray: """ @@ -15723,6 +16329,7 @@ def xpose6(m: Iterable[Iterable[float]]) -> ndarray: return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def xposeg( matrix: Union[ndarray, Iterable[Iterable[float]]], nrow: int, ncol: int @@ -15746,6 +16353,7 @@ def xposeg( return stypes.c_matrix_to_numpy(mout) +@spicelock_for_multithread @spice_error_check def zzdynrot(typid: int, center: int, et: float) -> Tuple[ndarray, int]: """ From 7257c3e0e670b49e5c72e090739b594042ef4380 Mon Sep 17 00:00:00 2001 From: Tommaso Pino Date: Thu, 6 May 2021 11:19:32 +0200 Subject: [PATCH 02/14] An example file to test ways of concurrency --- spiceConcurrentCall_test.py | 97 +++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 spiceConcurrentCall_test.py diff --git a/spiceConcurrentCall_test.py b/spiceConcurrentCall_test.py new file mode 100644 index 00000000..efd74365 --- /dev/null +++ b/spiceConcurrentCall_test.py @@ -0,0 +1,97 @@ +# %% +import spiceypy as spice # this imports the version 4.0.0 +import os + +# %% +import functools +import threading + +from spiceypy.spiceypy import spkezr + +spicelock = threading.RLock() + +def spicelock_for_multithread(f): + """ + :return: + """ + + @functools.wraps(f) + def lock(*args, **kwargs): + + with spicelock: + try: + res = f(*args, **kwargs) + return res + except BaseException: + raise + + return lock + + +# %% +from multiprocessing.dummy import Pool as ThreadPool + + + +# %% +b1900 = spice.b1900 +tb1900 = spicelock_for_multithread(b1900) + +# %% +print('Test thread pool without locking for b1900') +with ThreadPool() as pool: + test_b1900 = pool.map(lambda x: b1900(), range(10000)) + +print('Test thread pool with locking for b1900') +with ThreadPool() as pool: + test_tb1900 = pool.map(lambda x: tb1900(), range(10000)) + + + +# %% +pathKernels = 'path/to/kernels' + +defKernels = [ + 'naif0012.tls', # leaps seconds + 'gm_de431.tpc', # planetary constants + 'de430.bsp', # planetary position and velocity ephemeris + 'earth_fixed.tf', # ECEF reference system definition + 'earth_070425_370426_predict.bpc', # ECEF ephemeris + 'pck00010.tpc' # Other constants +] + +for k in defKernels: + spice.furnsh(os.path.join(pathKernels,k)) + +# %% +spkezr = spice.spkezr +tspkezr = spicelock_for_multithread(spkezr) +# %% +# testing the spicelock_for_multithread decorator +print('Test thread pool without locking for spkezr') +try: + with ThreadPool() as pool: + test_spkezr = pool.map(lambda x: spkezr('EARTH',x,'J2000','NONE','SUN'),test_b1900) +except BaseException as e: + print(e) + + +print('Test thread pool with locking for spkezr') +with ThreadPool() as pool: + test_tspkezr = pool.map(lambda x: tspkezr('EARTH',x,'J2000','NONE','SUN'),test_b1900) + +# %% +# testing the wrapt library +import wrapt +wb1900 = wrapt.synchronized(spicelock)(b1900) +wspkezr = wrapt.synchronized(spicelock)(spkezr) +# %% +print('Test thread pool with spicelock_for_multithread decorator for spkezr') +with ThreadPool() as pool: + test_tspkezr = pool.map(lambda x: tspkezr('EARTH',x,'J2000','NONE','SUN'),test_b1900) + +print('Test thread pool with wrapt.synchronized(spicelock) decorator for spkezr') +with ThreadPool() as pool: + test_wspkezr = pool.map(lambda x: wspkezr('EARTH',x,'J2000','NONE','SUN'),test_b1900) + +# %% From 17c7d9d3d89fb49f696e69c3763e32e359a4d8c3 Mon Sep 17 00:00:00 2001 From: Tommaso Pino Date: Thu, 6 May 2021 11:30:42 +0200 Subject: [PATCH 03/14] Add cap to disable @dec and Rlock --- spiceypy/__init__.py | 3 +++ spiceypy/spiceypy.py | 27 +++++++++++----------- spiceypy/utils/decorators.py | 45 ++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 spiceypy/utils/decorators.py diff --git a/spiceypy/__init__.py b/spiceypy/__init__.py index 00f85ac0..2f5c373a 100644 --- a/spiceypy/__init__.py +++ b/spiceypy/__init__.py @@ -31,3 +31,6 @@ # Default setting for error reporting so that programs don't just exit out! erract("set", 10, "return") errdev("set", 10, "null") + +# in order to enable the multithread decorator +spicelock_for_multithread.enabled = True \ No newline at end of file diff --git a/spiceypy/spiceypy.py b/spiceypy/spiceypy.py index 536d6c02..7d0885d3 100644 --- a/spiceypy/spiceypy.py +++ b/spiceypy/spiceypy.py @@ -34,6 +34,7 @@ from .utils.libspicehelper import libspice from . import config + from .utils.callbacks import ( UDFUNC, UDFUNS, @@ -74,34 +75,32 @@ _SPICE_EK_MAXQSEL = 100 # Twice the 50 in gcc-linux-64 _SPICE_EK_EKRCEX_ROOM_DEFAULT = 100 # Enough? +from .utils.decorators import SwitchedDecorator import threading -spicelock = threading.Lock() +spicelock = threading.RLock() -def spicelock_for_multithread(f): +def _spicelock_for_multithread(f): """ + Decorator for spiceypy to avoid concurrent calls to cspice lib. + :return: """ @functools.wraps(f) def lock(*args, **kwargs): - if not spicelock.locked(): - spicelock.acquire() + with spicelock: try: - # this try handle if some error occurs res = f(*args, **kwargs) - finally: - if spicelock.locked(): - spicelock.release() - else: - # some library methods calls other library methods, this "else" handle that - res = f(*args, **kwargs) - - return res + return res + except BaseException: + raise return lock +spicelock_for_multithread = SwitchedDecorator(_spicelock_for_multithread) + def check_for_spice_error(f: Optional[Callable]) -> None: """ Internal decorator function to check spice error system for failed calls @@ -14573,7 +14572,7 @@ def tkfram(typid: int) -> Tuple[ndarray, int, bool]: return stypes.c_matrix_to_numpy(matrix), next_frame.value, bool(found.value) -# @spicelock_for_multithread +@spicelock_for_multithread @spice_error_check def tkvrsn(item: str) -> str: """ diff --git a/spiceypy/utils/decorators.py b/spiceypy/utils/decorators.py new file mode 100644 index 00000000..8d7a7e07 --- /dev/null +++ b/spiceypy/utils/decorators.py @@ -0,0 +1,45 @@ +""" +The MIT License (MIT) + +Copyright (c) [2015-2021] [Andrew Annex] + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + +import functools + +class SwitchedDecorator: + def __init__(self, enabled_func): + self._enabled = False + self._enabled_func = enabled_func + + @property + def enabled(self): + return self._enabled + + @enabled.setter + def enabled(self, new_value): + if not isinstance(new_value, bool): + raise ValueError("enabled can only be set to a boolean value") + self._enabled = new_value + + def __call__(self, target): + if self._enabled: + return self._enabled_func(target) + return target \ No newline at end of file From 02dd860ba5184cd7c3c2bdfb989b993cb4f44363 Mon Sep 17 00:00:00 2001 From: Tommaso Pino Date: Thu, 6 May 2021 13:03:13 +0200 Subject: [PATCH 04/14] rem SwitchedDecorator and updated test --- spiceConcurrentCall_test.py | 30 ++++++++++++++++-------- spiceypy/__init__.py | 3 ++- spiceypy/spiceypy.py | 24 +++++++++++-------- spiceypy/utils/decorators.py | 45 ------------------------------------ 4 files changed, 38 insertions(+), 64 deletions(-) delete mode 100644 spiceypy/utils/decorators.py diff --git a/spiceConcurrentCall_test.py b/spiceConcurrentCall_test.py index efd74365..43280338 100644 --- a/spiceConcurrentCall_test.py +++ b/spiceConcurrentCall_test.py @@ -8,17 +8,26 @@ from spiceypy.spiceypy import spkezr -spicelock = threading.RLock() +_spicelock = threading.RLock() + +enablethreadinglock = False def spicelock_for_multithread(f): """ + Decorator for spiceypy to avoid concurrent calls to cspice lib. + :return: """ - @functools.wraps(f) def lock(*args, **kwargs): - - with spicelock: + if enablethreadinglock: + with _spicelock: + try: + res = f(*args, **kwargs) + return res + except BaseException: + raise + else: try: res = f(*args, **kwargs) return res @@ -27,7 +36,6 @@ def lock(*args, **kwargs): return lock - # %% from multiprocessing.dummy import Pool as ThreadPool @@ -39,10 +47,12 @@ def lock(*args, **kwargs): # %% print('Test thread pool without locking for b1900') +spice.enablethreadinglock = False with ThreadPool() as pool: - test_b1900 = pool.map(lambda x: b1900(), range(10000)) + test_b1900 = pool.map(lambda x: tb1900(), range(10000)) print('Test thread pool with locking for b1900') +spice.enablethreadinglock = True with ThreadPool() as pool: test_tb1900 = pool.map(lambda x: tb1900(), range(10000)) @@ -69,22 +79,24 @@ def lock(*args, **kwargs): # %% # testing the spicelock_for_multithread decorator print('Test thread pool without locking for spkezr') +spice.enablethreadinglock = False try: with ThreadPool() as pool: - test_spkezr = pool.map(lambda x: spkezr('EARTH',x,'J2000','NONE','SUN'),test_b1900) + test_spkezr = pool.map(lambda x: tspkezr('EARTH',x,'J2000','NONE','SUN'),test_b1900) except BaseException as e: print(e) print('Test thread pool with locking for spkezr') +spice.enablethreadinglock = True with ThreadPool() as pool: test_tspkezr = pool.map(lambda x: tspkezr('EARTH',x,'J2000','NONE','SUN'),test_b1900) # %% # testing the wrapt library import wrapt -wb1900 = wrapt.synchronized(spicelock)(b1900) -wspkezr = wrapt.synchronized(spicelock)(spkezr) +wb1900 = wrapt.synchronized(_spicelock)(b1900) +wspkezr = wrapt.synchronized(_spicelock)(spkezr) # %% print('Test thread pool with spicelock_for_multithread decorator for spkezr') with ThreadPool() as pool: diff --git a/spiceypy/__init__.py b/spiceypy/__init__.py index 2f5c373a..ef1c0e88 100644 --- a/spiceypy/__init__.py +++ b/spiceypy/__init__.py @@ -27,10 +27,11 @@ from .spiceypy import * from .utils import support_types from .utils import exceptions +from .spiceypy import enablethreadinglock # Default setting for error reporting so that programs don't just exit out! erract("set", 10, "return") errdev("set", 10, "null") # in order to enable the multithread decorator -spicelock_for_multithread.enabled = True \ No newline at end of file +enablethreadinglock = True \ No newline at end of file diff --git a/spiceypy/spiceypy.py b/spiceypy/spiceypy.py index 7d0885d3..61407578 100644 --- a/spiceypy/spiceypy.py +++ b/spiceypy/spiceypy.py @@ -75,31 +75,37 @@ _SPICE_EK_MAXQSEL = 100 # Twice the 50 in gcc-linux-64 _SPICE_EK_EKRCEX_ROOM_DEFAULT = 100 # Enough? -from .utils.decorators import SwitchedDecorator import threading -spicelock = threading.RLock() +_spicelock = threading.RLock() -def _spicelock_for_multithread(f): +enablethreadinglock = False + +def spicelock_for_multithread(f): """ Decorator for spiceypy to avoid concurrent calls to cspice lib. :return: """ - @functools.wraps(f) def lock(*args, **kwargs): - - with spicelock: + if enablethreadinglock: + with _spicelock: + try: + res = f(*args, **kwargs) + return res + except BaseException: + raise + else: try: res = f(*args, **kwargs) return res except BaseException: raise - return lock -spicelock_for_multithread = SwitchedDecorator(_spicelock_for_multithread) + return lock + def check_for_spice_error(f: Optional[Callable]) -> None: """ @@ -10479,7 +10485,7 @@ def q2m(q: ndarray) -> ndarray: return stypes.c_matrix_to_numpy(mout) -# @spicelock_for_multithread +@spicelock_for_multithread @spice_error_check def qcktrc(tracelen: int = _default_len_out) -> str: """ diff --git a/spiceypy/utils/decorators.py b/spiceypy/utils/decorators.py deleted file mode 100644 index 8d7a7e07..00000000 --- a/spiceypy/utils/decorators.py +++ /dev/null @@ -1,45 +0,0 @@ -""" -The MIT License (MIT) - -Copyright (c) [2015-2021] [Andrew Annex] - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -""" - -import functools - -class SwitchedDecorator: - def __init__(self, enabled_func): - self._enabled = False - self._enabled_func = enabled_func - - @property - def enabled(self): - return self._enabled - - @enabled.setter - def enabled(self, new_value): - if not isinstance(new_value, bool): - raise ValueError("enabled can only be set to a boolean value") - self._enabled = new_value - - def __call__(self, target): - if self._enabled: - return self._enabled_func(target) - return target \ No newline at end of file From b15cf6934f1f8e6e2ac827d7098eb762cd59b84e Mon Sep 17 00:00:00 2001 From: Tommaso Pino Date: Sat, 8 May 2021 09:55:23 +0200 Subject: [PATCH 05/14] Added Context manager and test for CI --- .gitignore | 2 + spiceConcurrentCall_test.py | 109 --------------------------------- spiceypy/config.py | 2 + spiceypy/spiceypy.py | 56 +++++++++++++++-- spiceypy/tests/test_wrapper.py | 16 +++++ 5 files changed, 72 insertions(+), 113 deletions(-) delete mode 100644 spiceConcurrentCall_test.py diff --git a/.gitignore b/.gitignore index eb4ea7a6..200aadd0 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,5 @@ spiceypy/utils/__pycache__/ *.whl .pytest_cache/ *.sqlite3 +spiceypy/utils/cspice.dll +.vscode diff --git a/spiceConcurrentCall_test.py b/spiceConcurrentCall_test.py deleted file mode 100644 index 43280338..00000000 --- a/spiceConcurrentCall_test.py +++ /dev/null @@ -1,109 +0,0 @@ -# %% -import spiceypy as spice # this imports the version 4.0.0 -import os - -# %% -import functools -import threading - -from spiceypy.spiceypy import spkezr - -_spicelock = threading.RLock() - -enablethreadinglock = False - -def spicelock_for_multithread(f): - """ - Decorator for spiceypy to avoid concurrent calls to cspice lib. - - :return: - """ - @functools.wraps(f) - def lock(*args, **kwargs): - if enablethreadinglock: - with _spicelock: - try: - res = f(*args, **kwargs) - return res - except BaseException: - raise - else: - try: - res = f(*args, **kwargs) - return res - except BaseException: - raise - - return lock - -# %% -from multiprocessing.dummy import Pool as ThreadPool - - - -# %% -b1900 = spice.b1900 -tb1900 = spicelock_for_multithread(b1900) - -# %% -print('Test thread pool without locking for b1900') -spice.enablethreadinglock = False -with ThreadPool() as pool: - test_b1900 = pool.map(lambda x: tb1900(), range(10000)) - -print('Test thread pool with locking for b1900') -spice.enablethreadinglock = True -with ThreadPool() as pool: - test_tb1900 = pool.map(lambda x: tb1900(), range(10000)) - - - -# %% -pathKernels = 'path/to/kernels' - -defKernels = [ - 'naif0012.tls', # leaps seconds - 'gm_de431.tpc', # planetary constants - 'de430.bsp', # planetary position and velocity ephemeris - 'earth_fixed.tf', # ECEF reference system definition - 'earth_070425_370426_predict.bpc', # ECEF ephemeris - 'pck00010.tpc' # Other constants -] - -for k in defKernels: - spice.furnsh(os.path.join(pathKernels,k)) - -# %% -spkezr = spice.spkezr -tspkezr = spicelock_for_multithread(spkezr) -# %% -# testing the spicelock_for_multithread decorator -print('Test thread pool without locking for spkezr') -spice.enablethreadinglock = False -try: - with ThreadPool() as pool: - test_spkezr = pool.map(lambda x: tspkezr('EARTH',x,'J2000','NONE','SUN'),test_b1900) -except BaseException as e: - print(e) - - -print('Test thread pool with locking for spkezr') -spice.enablethreadinglock = True -with ThreadPool() as pool: - test_tspkezr = pool.map(lambda x: tspkezr('EARTH',x,'J2000','NONE','SUN'),test_b1900) - -# %% -# testing the wrapt library -import wrapt -wb1900 = wrapt.synchronized(_spicelock)(b1900) -wspkezr = wrapt.synchronized(_spicelock)(spkezr) -# %% -print('Test thread pool with spicelock_for_multithread decorator for spkezr') -with ThreadPool() as pool: - test_tspkezr = pool.map(lambda x: tspkezr('EARTH',x,'J2000','NONE','SUN'),test_b1900) - -print('Test thread pool with wrapt.synchronized(spicelock) decorator for spkezr') -with ThreadPool() as pool: - test_wspkezr = pool.map(lambda x: wspkezr('EARTH',x,'J2000','NONE','SUN'),test_b1900) - -# %% diff --git a/spiceypy/config.py b/spiceypy/config.py index 293854c6..1b1cdbc4 100644 --- a/spiceypy/config.py +++ b/spiceypy/config.py @@ -23,3 +23,5 @@ """ catch_false_founds = True + +enable_threading_lock = True diff --git a/spiceypy/spiceypy.py b/spiceypy/spiceypy.py index 61407578..a7808a77 100644 --- a/spiceypy/spiceypy.py +++ b/spiceypy/spiceypy.py @@ -79,8 +79,6 @@ _spicelock = threading.RLock() -enablethreadinglock = False - def spicelock_for_multithread(f): """ Decorator for spiceypy to avoid concurrent calls to cspice lib. @@ -89,7 +87,7 @@ def spicelock_for_multithread(f): """ @functools.wraps(f) def lock(*args, **kwargs): - if enablethreadinglock: + if config.enable_threading_lock: with _spicelock: try: res = f(*args, **kwargs) @@ -103,7 +101,6 @@ def lock(*args, **kwargs): except BaseException: raise - return lock @@ -178,6 +175,57 @@ def wrapper(*args, **kwargs): return wrapper +@contextmanager +def no_threading_lock() -> Iterator[None]: + """ + Temporarily disables spiceypy default behavior which locks the access to the + SPICE library from multithreading cuncurrent operations. + All spice functions executed within the context manager will no longer lock the + access. + """ + current_threading_lock_state = config.enable_threading_lock + config.enable_threading_lock = False + yield + config.enable_threading_lock = current_threading_lock_state + + +@contextmanager +def threading_lock() -> Iterator[None]: + """ + Temporarily enables spiceypy default behavior which locks the access to the + SPICE library from multithreading cuncurrent operations. + All spice functions executed within the context manager will lock the + access preventing the access from other cuncurrent threads. + """ + current_threading_lock_state = config.enable_threading_lock + config.enable_threading_lock = True + yield + config.enable_threading_lock = current_threading_lock_state + + +def threading_lock_off() -> None: + """ + Method that turns off threading lock + + """ + config.enable_threading_lock = False + + +def threading_lock_on() -> None: + """ + Method that turns on threading lock + + """ + config.enable_threading_lock = True + + +def get_threading_lock_state() -> bool: + """ + Returns the current threading lock state + + :return: + """ + return config.enable_threading_lock @contextmanager def no_found_check() -> Iterator[None]: diff --git a/spiceypy/tests/test_wrapper.py b/spiceypy/tests/test_wrapper.py index 68dc772d..b031cbfa 100644 --- a/spiceypy/tests/test_wrapper.py +++ b/spiceypy/tests/test_wrapper.py @@ -47,6 +47,22 @@ def setup_module(module): download_kernels() +def test_threading_lock(): + nOperations = 1000 + spice.kclear() + spice.furnsh(CoreKernels.testMetaKernel) + et = spice.str2et("Dec 25, 2007") + from multiprocessing import ThreadPool + ets = np.array([et]*nOperations) + state, ltime = spice.spkezr("Moon", et, "J2000", "NONE", "EARTH") + state = np.array([state]*nOperations) + with ThreadPool(processes = 2) as pool: + with spice.threading_lock(): + states = pool.map(lambda x: spice.spkezr("Moon", x, "J2000", "NONE", "EARTH")[0],ets) + states = np.array(states) + spice.kclear() + npt.assert_array_almost_equal(states, state, decimal=5) + def test_appndc(): test_cell = spice.cell_char(10, 10) spice.appndc("one", test_cell) From db2535e150d2ebe0446ed3b9c5f05b6d73bdc41d Mon Sep 17 00:00:00 2001 From: Tommaso Pino Date: Sat, 8 May 2021 10:08:42 +0200 Subject: [PATCH 06/14] removed config --- spiceypy/__init__.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/spiceypy/__init__.py b/spiceypy/__init__.py index ef1c0e88..88bcb673 100644 --- a/spiceypy/__init__.py +++ b/spiceypy/__init__.py @@ -32,6 +32,3 @@ # Default setting for error reporting so that programs don't just exit out! erract("set", 10, "return") errdev("set", 10, "null") - -# in order to enable the multithread decorator -enablethreadinglock = True \ No newline at end of file From acfdc0d02c15599dfb9b76f5b6fc0178d936e939 Mon Sep 17 00:00:00 2001 From: Tommaso Pino Date: Sun, 9 May 2021 15:41:08 +0200 Subject: [PATCH 07/14] Minor correction --- spiceypy/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/spiceypy/__init__.py b/spiceypy/__init__.py index 88bcb673..00f85ac0 100644 --- a/spiceypy/__init__.py +++ b/spiceypy/__init__.py @@ -27,7 +27,6 @@ from .spiceypy import * from .utils import support_types from .utils import exceptions -from .spiceypy import enablethreadinglock # Default setting for error reporting so that programs don't just exit out! erract("set", 10, "return") From 6997cd566eb9b900f34a225e4af29c6597220a50 Mon Sep 17 00:00:00 2001 From: Tommaso Date: Mon, 17 May 2021 11:54:57 +0200 Subject: [PATCH 08/14] Update .gitignore Removed unnecessary elements --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 200aadd0..dd5187fc 100644 --- a/.gitignore +++ b/.gitignore @@ -45,5 +45,4 @@ spiceypy/utils/__pycache__/ *.whl .pytest_cache/ *.sqlite3 -spiceypy/utils/cspice.dll -.vscode + From c4235654eb23439c324d3cdd818006b7a5caebc3 Mon Sep 17 00:00:00 2001 From: Tommaso Date: Tue, 25 May 2021 11:37:10 +0200 Subject: [PATCH 09/14] decoretor @spice_error_check removed from qcktrc It avoid the RecursionError --- spiceypy/spiceypy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spiceypy/spiceypy.py b/spiceypy/spiceypy.py index 442c59cd..edcd251c 100644 --- a/spiceypy/spiceypy.py +++ b/spiceypy/spiceypy.py @@ -10598,7 +10598,7 @@ def q2m(q: ndarray) -> ndarray: @spicelock_for_multithread -@spice_error_check +# @spice_error_check # Commented in order to avoid RecursionError def qcktrc(tracelen: int = _default_len_out) -> str: """ Return a string containing a traceback. From 929453dc36b0a79e29c8e6af23252284fa70aa82 Mon Sep 17 00:00:00 2001 From: Andrew Annex Date: Sun, 30 May 2021 10:29:20 -0400 Subject: [PATCH 10/14] Update test_wrapper.py fixing test import --- spiceypy/tests/test_wrapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spiceypy/tests/test_wrapper.py b/spiceypy/tests/test_wrapper.py index 0e9d5c41..d7286c6e 100644 --- a/spiceypy/tests/test_wrapper.py +++ b/spiceypy/tests/test_wrapper.py @@ -52,7 +52,7 @@ def test_threading_lock(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et("Dec 25, 2007") - from multiprocessing import ThreadPool + from multiprocessing.pool import ThreadPool ets = np.array([et]*nOperations) state, ltime = spice.spkezr("Moon", et, "J2000", "NONE", "EARTH") state = np.array([state]*nOperations) From c5fd940b1f81f78c7817577574ae7c328b3a90d2 Mon Sep 17 00:00:00 2001 From: Tommaso Date: Wed, 8 Sep 2021 10:06:05 +0200 Subject: [PATCH 11/14] Update README.rst --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 9ae08cce..0943efe4 100644 --- a/README.rst +++ b/README.rst @@ -124,3 +124,4 @@ Acknowledgements `DaRasch `__ wrote spiceminer, which I looked at to get SpiceCells working, thanks! + From 21a3e3db4822d58353f0f9adf9844aecaa9900bb Mon Sep 17 00:00:00 2001 From: Tommaso Date: Wed, 8 Sep 2021 10:16:39 +0200 Subject: [PATCH 12/14] make usage of 'ctx' to avoid code repetition --- spiceypy/spiceypy.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/spiceypy/spiceypy.py b/spiceypy/spiceypy.py index edcd251c..6c7cd0ac 100644 --- a/spiceypy/spiceypy.py +++ b/spiceypy/spiceypy.py @@ -90,20 +90,13 @@ def spicelock_for_multithread(f): """ @functools.wraps(f) def lock(*args, **kwargs): - if config.enable_threading_lock: - with _spicelock: - try: - res = f(*args, **kwargs) - return res - except BaseException: - raise - else: + ctx = _spicelock if config.enable_threading_lock else contextlib.suppress() + with ctx: try: res = f(*args, **kwargs) return res except BaseException: raise - return lock From 7aeee8d713a6da4a3eb9b1a1d8a8c850420a62ca Mon Sep 17 00:00:00 2001 From: Tommaso Pino Date: Mon, 13 Sep 2021 11:46:15 +0200 Subject: [PATCH 13/14] added documentation for multithread --- docs/multithread.rst | 28 ++++++++++++++++++++++++++++ spiceypy/spiceypy.py | 8 +++----- 2 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 docs/multithread.rst diff --git a/docs/multithread.rst b/docs/multithread.rst new file mode 100644 index 00000000..18faeee9 --- /dev/null +++ b/docs/multithread.rst @@ -0,0 +1,28 @@ +Multithreading in SpiceyPy +====================== + +SpiceyPy by default enable a semaphore to avoid a cuncurrent call to the SpiceyPy functions. + +This semaphore system is intended to avoind a cuncurrent call to the kernel from different threads that could make fail +the called routine (e.g. 2 cuncurrent calls to 'spkezr' may fail into a DAF error due to spice internal errors) + +The handling of multiprocesses is not the scope of this feature. + +Occasionaly Enabling Multithreading +---------------- + +In order to activate the multithreading feature only when it is required, it is possible to disable the default behavior and use +the provided SpiceyPy function that returns the context manager to be used only where the feature is + +.. code:: python + + import spiceypy as spice + + spice.threading_lock_on() # the SpiceyPy multithread handler is disabled + + + with spice.threading_lock(): # the SpiceyPy multithread handler is enabled + ... + # do stuff with multithread + + # the SpiceyPy multithread handler is disabled again diff --git a/spiceypy/spiceypy.py b/spiceypy/spiceypy.py index 6c7cd0ac..371b5f03 100644 --- a/spiceypy/spiceypy.py +++ b/spiceypy/spiceypy.py @@ -22,12 +22,12 @@ SOFTWARE. """ import warnings -from contextlib import contextmanager +from contextlib import contextmanager, suppress from datetime import datetime, timezone import functools import ctypes from typing import Callable, Iterator, Iterable, Optional, Tuple, Union, Sequence - +import threading import numpy from numpy import ndarray, str_ @@ -78,8 +78,6 @@ _SPICE_EK_MAXQSEL = 100 # Twice the 50 in gcc-linux-64 _SPICE_EK_EKRCEX_ROOM_DEFAULT = 100 # Enough? -import threading - _spicelock = threading.RLock() def spicelock_for_multithread(f): @@ -90,7 +88,7 @@ def spicelock_for_multithread(f): """ @functools.wraps(f) def lock(*args, **kwargs): - ctx = _spicelock if config.enable_threading_lock else contextlib.suppress() + ctx = _spicelock if config.enable_threading_lock else suppress() with ctx: try: res = f(*args, **kwargs) From 3654fad656feca612c4ac99af45c7f62d155d875 Mon Sep 17 00:00:00 2001 From: Tommaso Pino Date: Sat, 27 Nov 2021 11:44:06 +0100 Subject: [PATCH 14/14] added missing tests for threading lock --- spiceypy/tests/test_wrapper.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/spiceypy/tests/test_wrapper.py b/spiceypy/tests/test_wrapper.py index d7286c6e..f2d2a85a 100644 --- a/spiceypy/tests/test_wrapper.py +++ b/spiceypy/tests/test_wrapper.py @@ -42,7 +42,6 @@ cwd, ) - def setup_module(module): download_kernels() @@ -63,6 +62,30 @@ def test_threading_lock(): spice.kclear() npt.assert_array_almost_equal(states, state, decimal=5) +def test_no_threading_lock(): + nOperations = 10 + spice.kclear() + spice.furnsh(CoreKernels.testMetaKernel) + et = spice.str2et("Dec 25, 2007") + ets = np.array([et]*nOperations) + state, ltime = spice.spkezr("Moon", et, "J2000", "NONE", "EARTH") + state = np.array([state]*nOperations) + with spice.no_threading_lock(): + states = [] + for et in ets: + states.append(spice.spkezr("Moon", ets, "J2000", "NONE", "EARTH")[0]) + states = np.array(states) + spice.kclear() + npt.assert_array_almost_equal(states, state, decimal=5) + +def test_change_threading_lock(): + spice.threading_lock_off() + stateOff = spice.get_threading_lock_state() + spice.threading_lock_on() + stateOn = spice.get_threading_lock_state() + assert stateOff == False + assert stateOn == True + def test_appndc(): test_cell = spice.cell_char(10, 10) spice.appndc("one", test_cell)