diff --git a/google/cloud/spanner_v1/_helpers.py b/google/cloud/spanner_v1/_helpers.py index 62d7a26e02..1f4bf5b174 100644 --- a/google/cloud/spanner_v1/_helpers.py +++ b/google/cloud/spanner_v1/_helpers.py @@ -31,6 +31,7 @@ from google.cloud.spanner_v1 import TypeCode from google.cloud.spanner_v1 import ExecuteSqlRequest from google.cloud.spanner_v1 import JsonObject +from google.cloud.spanner_v1.request_id_header import with_request_id # Validation error messages NUMERIC_MAX_SCALE_ERR_MSG = ( diff --git a/google/cloud/spanner_v1/request_id_header.py b/google/cloud/spanner_v1/request_id_header.py index 6e4e0e3fd8..8376778273 100644 --- a/google/cloud/spanner_v1/request_id_header.py +++ b/google/cloud/spanner_v1/request_id_header.py @@ -13,7 +13,6 @@ # limitations under the License. import os -import threading REQ_ID_VERSION = 1 # The version of the x-goog-spanner-request-id spec. REQ_ID_HEADER_KEY = "x-goog-spanner-request-id" @@ -38,5 +37,6 @@ def generate_rand_uint64(): def with_request_id(client_id, channel_id, nth_request, attempt, other_metadata=[]): req_id = f"{REQ_ID_VERSION}.{REQ_RAND_PROCESS_ID}.{client_id}.{channel_id}.{nth_request}.{attempt}" - other_metadata.append((REQ_ID_HEADER_KEY, req_id)) - return other_metadata + all_metadata = other_metadata.copy() + all_metadata.append((REQ_ID_HEADER_KEY, req_id)) + return all_metadata diff --git a/tests/unit/test_atomic_counter.py b/tests/unit/test_atomic_counter.py index fe50e61587..e4c41de200 100644 --- a/tests/unit/test_atomic_counter.py +++ b/tests/unit/test_atomic_counter.py @@ -75,7 +75,7 @@ def do_work(): random.shuffle(threads) for th in threads: th.join() - assert th.is_alive() == False + assert not th.is_alive() # Finally the result should be n*m assert ac.value == n * m