aboutsummaryrefslogtreecommitdiff
path: root/pyecsca/ec/context.py
diff options
context:
space:
mode:
authorJ08nY2023-02-12 17:40:10 +0100
committerJ08nY2023-02-12 17:40:10 +0100
commit7c3b286a78a294a0eb6cd052682b9ee92420fa4d (patch)
tree6ac122b0afc3aff96fac0185f7068483d12230c7 /pyecsca/ec/context.py
parentd4ebdf7e7ed1867b49f353ade6c130b5dcbc3ed1 (diff)
downloadpyecsca-7c3b286a78a294a0eb6cd052682b9ee92420fa4d.tar.gz
pyecsca-7c3b286a78a294a0eb6cd052682b9ee92420fa4d.tar.zst
pyecsca-7c3b286a78a294a0eb6cd052682b9ee92420fa4d.zip
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