Skip to content

Commit

Permalink
Make run_token a property on Scope
Browse files Browse the repository at this point in the history
Eventually this should just be a value.
  • Loading branch information
philandstuff committed Jan 15, 2025
1 parent 1e132ac commit b06a692
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python/cog/server/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from ..types import ExperimentalFeatureWarning


# This is a bit of a mess right now, Scope should just be a dictionary-like
# object that has plain values. Right now it's a ContextVar that wraps other
# ContextVars; in future it should be a ContextVar that wraps a bag of values.
class Scope:
def __init__(
self,
Expand All @@ -14,7 +17,11 @@ def __init__(
run_token: Callable[[], Optional[str]],
) -> None:
self.record_metric = record_metric
self.run_token = run_token
self._run_token = run_token

@property
def run_token(self) -> Optional[str]:
return self._run_token()


_current_scope: ContextVar[Optional[Scope]] = ContextVar("scope", default=None)
Expand Down

0 comments on commit b06a692

Please sign in to comment.