def check_uwsgi_thread_support(): # type: () -> bool # We check two things here: # # 1. uWSGI doesn't run in threaded mode by default -- issue a warning if # that's the case. # # 2. Additionally, if uWSGI is running in preforking mode (default), it needs # the --py-call-uwsgi-fork-hooks option for the SDK to work properly. This # is because any background threads spawned before the main process is # forked are NOT CLEANED UP IN THE CHILDREN BY DEFAULT even if # --enable-threads is on. One has to explicitly provide # --py-call-uwsgi-fork-hooks to force uWSGI to run regular cpython # after-fork hooks that take care of cleaning up stale thread data. try: from uwsgi import opt # type: ignore except ImportError: returnTrue
from sentry_sdk.consts import FALSE_VALUES
def enabled(option): # type: (str) -> bool
value = opt.get(option, False) if isinstance(value, bool): return value
if isinstance(value, bytes): try:
value = value.decode() except Exception: pass
return value and str(value).lower() notin FALSE_VALUES
# When `threads` is passed in as a uwsgi option, # `enable-threads` is implied on.
threads_enabled = "threads"in opt or enabled("enable-threads")
fork_hooks_on = enabled("py-call-uwsgi-fork-hooks")
lazy_mode = enabled("lazy-apps") or enabled("lazy")
if lazy_mode andnot threads_enabled: from warnings import warn
warn(
Warning( "IMPORTANT: " "We detected the use of uWSGI without thread support. " "This might lead to unexpected issues. " 'Please run uWSGI with "--enable-threads" for full support.'
)
)
returnFalse
elifnot lazy_mode and (not threads_enabled ornot fork_hooks_on): from warnings import warn
warn(
Warning( "IMPORTANT: " "We detected the use of uWSGI in preforking mode without " "thread support. This might lead to crashing workers. " 'Please run uWSGI with both "--enable-threads" and ' '"--py-call-uwsgi-fork-hooks" for full support.'
)
)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.