Skip to content

Commit 6794530

Browse files
Apply suggestions from code review
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 6b82df1 commit 6794530

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

test/nginx_opentracing_test.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
import app_pb2_grpc as app_service
1515
import docker
1616
import grpc
17-
from absl import logging
18-
1917
try:
20-
# Initialize the abseil logging system - this prevents the "WARNING: All log messages..." message
21-
logging.set_verbosity(logging.INFO)
22-
logging.use_absl_handler()
18+
from absl import logging as absl_logging
19+
# Prevent noisy "All log messages ..." banner
20+
absl_logging.set_verbosity(absl_logging.INFO)
21+
absl_logging.use_absl_handler()
2322
except ImportError:
23+
# absl is optional – continue with stdlib logging defaults
2424
pass
2525

2626

@@ -131,10 +131,9 @@ def _setup_grpc(self):
131131
self.grpcConn = grpc.insecure_channel("localhost:8081")
132132
try:
133133
grpc.channel_ready_future(self.grpcConn).result(timeout=10)
134-
except grpc.FutureTimeoutError:
135-
raise RuntimeError("Error connecting to gRPC server")
134+
except grpc.FutureTimeoutError as err:
135+
raise RuntimeError("Error connecting to gRPC server") from err
136136
return self.grpcConn
137-
138137
def tearDown(self):
139138
self._stopDocker()
140139
logdir = None
@@ -267,18 +266,10 @@ def testGrpcPropagation(self):
267266
app = app_service.AppStub(grpc_conn)
268267
try:
269268
app.CheckTraceHeader(app_messages.Empty())
270-
except Exception as e:
271-
# Close the connection before allowing any exceptions to propagate
272-
if self.grpcConn:
269+
finally:
270+
if self.grpcConn is not None:
273271
self.grpcConn.close()
274272
self.grpcConn = None
275-
raise
276-
277-
# Explicitly close the connection before stopping Docker
278-
if self.grpcConn:
279-
self.grpcConn.close()
280-
self.grpcConn = None
281-
282273
self._stopEnvironment()
283274
self.assertEqual(len(self.nginx_traces), 2)
284275

0 commit comments

Comments
 (0)