Merge pull request #11627 from robertwb/import-fix-155451253
Fix thread local to be initialized on every thread.
diff --git a/sdks/python/apache_beam/utils/subprocess_server.py b/sdks/python/apache_beam/utils/subprocess_server.py
index 92b60b5..3ecd9fa 100644
--- a/sdks/python/apache_beam/utils/subprocess_server.py
+++ b/sdks/python/apache_beam/utils/subprocess_server.py
@@ -161,8 +161,9 @@
BEAM_GROUP_ID = 'org.apache.beam'
JAR_CACHE = os.path.expanduser("~/.apache_beam/cache/jars")
- _BEAM_SERVICES = threading.local()
- _BEAM_SERVICES.replacements = {}
+ _BEAM_SERVICES = type(
+ 'local', (threading.local, ),
+ dict(__init__=lambda self: setattr(self, 'replacements', {})))()
def __init__(self, stub_class, path_to_jar, java_arguments):
super(JavaJarServer, self).__init__(