chadrik commented on a change in pull request #12881:
URL: https://github.com/apache/beam/pull/12881#discussion_r491722757
##########
File path: sdks/python/apache_beam/runners/worker/statecache.py
##########
@@ -44,15 +48,17 @@ class Metrics(object):
PREFIX = "beam:metric:statecache:"
def __init__(self):
+ # type: () -> None
self._context = threading.local()
def initialize(self):
+ # type: () -> None
+
"""Needs to be called once per thread to initialize the local metrics
cache.
"""
if hasattr(self._context, 'metrics'):
return # Already initialized
- self._context.metrics = collections.defaultdict(
- int) # type: DefaultDict[Hashable, int]
Review comment:
Removed this annotation because it's invalid: you can't add
annotations to an attribute of another class (non-self attribute). I've
noticed there's definitely a need for a typed version of `threading.local`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]