MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _metadata_env

Function _metadata_env

pymongo/pool_options.py:161–195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

159
160
161def _metadata_env() -> dict[str, Any]:
162 env: dict[str, Any] = {}
163 container = get_container_env_info()
164 if container:
165 env["container"] = container
166 # Skip if multiple (or no) envs are matched.
167 if (_is_lambda(), _is_azure_func(), _is_gcp_func(), _is_vercel()).count(True) != 1:
168 return env
169 if _is_lambda():
170 env["name"] = "aws.lambda"
171 region = os.getenv("AWS_REGION")
172 if region:
173 env["region"] = region
174 memory_mb = _getenv_int("AWS_LAMBDA_FUNCTION_MEMORY_SIZE")
175 if memory_mb is not None:
176 env["memory_mb"] = memory_mb
177 elif _is_azure_func():
178 env["name"] = "azure.func"
179 elif _is_gcp_func():
180 env["name"] = "gcp.func"
181 region = os.getenv("FUNCTION_REGION")
182 if region:
183 env["region"] = region
184 memory_mb = _getenv_int("FUNCTION_MEMORY_MB")
185 if memory_mb is not None:
186 env["memory_mb"] = memory_mb
187 timeout_sec = _getenv_int("FUNCTION_TIMEOUT_SEC")
188 if timeout_sec is not None:
189 env["timeout_sec"] = timeout_sec
190 elif _is_vercel():
191 env["name"] = "vercel"
192 region = os.getenv("VERCEL_REGION")
193 if region:
194 env["region"] = region
195 return env
196
197
198_MAX_METADATA_SIZE = 512

Callers 1

__init__Method · 0.85

Calls 6

get_container_env_infoFunction · 0.85
_is_lambdaFunction · 0.85
_is_azure_funcFunction · 0.85
_is_gcp_funcFunction · 0.85
_is_vercelFunction · 0.85
_getenv_intFunction · 0.85

Tested by

no test coverage detected