Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Multithread Requests #410

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ spiceypy/utils/__pycache__/
*.whl
.pytest_cache/
*.sqlite3
spiceypy/utils/cspice.dll
.vscode
/badhashkernel.txt
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,4 @@ Acknowledgements
`DaRasch <https://github.com/DaRasch>`__ wrote spiceminer, which I
looked at to get SpiceCells working, thanks!


28 changes: 28 additions & 0 deletions docs/multithread.rst
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions spiceypy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@
"""

catch_false_founds = True

enable_threading_lock = True
Loading