Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions google/cloud/logging_v2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@
import os
import sys

try:
from google.cloud.logging_v2 import _gapic
except ImportError: # pragma: NO COVER
_HAVE_GRPC = False
_gapic = None
else:
_HAVE_GRPC = True

import google.api_core.client_options
from google.cloud.client import ClientWithProject
Expand All @@ -48,6 +41,19 @@


_DISABLE_GRPC = os.getenv(DISABLE_GRPC, False)
_HAVE_GRPC = False

try:
if not _DISABLE_GRPC:
# only import if DISABLE_GRPC is not set
from google.cloud.logging_v2 import _gapic

_HAVE_GRPC = True
except ImportError: # pragma: NO COVER
# could not import gapic library. Fall back to HTTP mode
_HAVE_GRPC = False
_gapic = None

_USE_GRPC = _HAVE_GRPC and not _DISABLE_GRPC

_GAE_RESOURCE_TYPE = "gae_app"
Expand Down