aboutsummaryrefslogtreecommitdiff
path: root/pyecsca/ec/context.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyecsca/ec/context.py')
-rw-r--r--pyecsca/ec/context.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/pyecsca/ec/context.py b/pyecsca/ec/context.py
index a0fd3c2..691ae71 100644
--- a/pyecsca/ec/context.py
+++ b/pyecsca/ec/context.py
@@ -240,9 +240,7 @@ class PathContext(Context):
)
-_actual_context: ContextVar[Context] = ContextVar(
- "operational_context", default=NullContext()
-)
+_actual_context: Context = NullContext()
class _ContextManager:
@@ -260,7 +258,7 @@ class _ContextManager:
@public
def getcontext() -> Context:
"""Get the current thread/task context."""
- return _actual_context.get()
+ return _actual_context
@public
@@ -271,7 +269,10 @@ def setcontext(ctx: Context) -> Token:
:param ctx: A context to set.
:return: A token to restore previous context.
"""
- return _actual_context.set(ctx)
+ global _actual_context
+ old = _actual_context
+ _actual_context = ctx
+ return old
@public
@@ -281,7 +282,8 @@ def resetcontext(token: Token):
:param token: A token to restore.
"""
- _actual_context.reset(token)
+ global _actual_context
+ _actual_context = token
@public