Skip to content

gh-128555: Add 'context' keyword parameter to Thread. #128209

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

Closed
wants to merge 9 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Revise "decimal' docs, adding note about flag.
  • Loading branch information
nascheme committed Feb 21, 2025
commit 53eb72d5511ab0f6e2cd6c0c8b8ea6c52db45c6b
21 changes: 14 additions & 7 deletions Doc/library/decimal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1884,13 +1884,20 @@ the current thread.

If :func:`setcontext` has not been called before :func:`getcontext`, then
:func:`getcontext` will automatically create a new context for use in the
current thread.

The new context is copied from a prototype context called *DefaultContext*. To
control the defaults so that each thread will use the same values throughout the
application, directly modify the *DefaultContext* object. This should be done
*before* any threads are started so that there won't be a race condition between
threads calling :func:`getcontext`. For example::
current thread. New context objects have default values set from the
:data:`decimal.DefaultContext` object.

The :data:`sys.flags.thread_inherit_context` flag affects the context for
new threads. If the flag is false, new threads will start with an empty
context. In this case, :func:`getcontext` will create a new context object
when called and use the default values from *DefaultContext*. If the flag
is true, new threads will start with a copy of context from the caller of
:meth:`Thread.start`.

To control the defaults so that each thread will use the same values throughout
the application, directly modify the *DefaultContext* object. This should be
done *before* any threads are started so that there won't be a race condition
between threads calling :func:`getcontext`. For example::

# Set applicationwide defaults for all threads about to be launched
DefaultContext.prec = 12
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy