Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ab570ef

Browse filesBrowse files
feat: avoid importing grpc when explicitly disabled (#416)
1 parent eed5396 commit ab570ef
Copy full SHA for ab570ef

File tree

Expand file treeCollapse file tree

1 file changed

+13
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-7
lines changed

‎google/cloud/logging_v2/client.py

Copy file name to clipboardExpand all lines: google/cloud/logging_v2/client.py
+13-7Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@
1818
import os
1919
import sys
2020

21-
try:
22-
from google.cloud.logging_v2 import _gapic
23-
except ImportError: # pragma: NO COVER
24-
_HAVE_GRPC = False
25-
_gapic = None
26-
else:
27-
_HAVE_GRPC = True
2821

2922
import google.api_core.client_options
3023
from google.cloud.client import ClientWithProject
@@ -48,6 +41,19 @@
4841

4942

5043
_DISABLE_GRPC = os.getenv(DISABLE_GRPC, False)
44+
_HAVE_GRPC = False
45+
46+
try:
47+
if not _DISABLE_GRPC:
48+
# only import if DISABLE_GRPC is not set
49+
from google.cloud.logging_v2 import _gapic
50+
51+
_HAVE_GRPC = True
52+
except ImportError: # pragma: NO COVER
53+
# could not import gapic library. Fall back to HTTP mode
54+
_HAVE_GRPC = False
55+
_gapic = None
56+
5157
_USE_GRPC = _HAVE_GRPC and not _DISABLE_GRPC
5258

5359
_GAE_RESOURCE_TYPE = "gae_app"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.