Skip to content

Commit

Permalink
Improve macOS pthread detection exception handling
Browse files Browse the repository at this point in the history
This commit adds the pthread library loading exception to
the logger and assumes that the current thread is the main
thread if no pthread library is found.
  • Loading branch information
elevans committed Jul 19, 2024
1 parent 7667a09 commit 972592d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/imagej/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1530,10 +1530,13 @@ def _macos_is_main_thread():
# try to load the pthread library
try:
pthread = cdll.LoadLibrary("libpthread.dylib")
except OSError as e:
print("No pthread library found.", e)
except OSError as exc:
_log_exception(_logger, exc)
print("No pthread library found.")
# assume the current thread is the main thread
return True

# detect if main thread
# detect if the current thread is the main thread
if pthread.pthread_main_np() == 1:
return True
else:
Expand Down

0 comments on commit 972592d

Please sign in to comment.