Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit b51ca7f

Browse files
authored
Adding thread prefix for ThreadPoolExecutor in Pub/Sub. (#4480)
1 parent df5a803 commit b51ca7f

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • google/cloud/pubsub_v1/subscriber/policy

google/cloud/pubsub_v1/subscriber/policy/thread.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from concurrent import futures
1818
import logging
19+
import sys
1920
import threading
2021

2122
import grpc
@@ -106,7 +107,14 @@ def __init__(self, client, subscription, flow_control=types.FlowControl(),
106107

107108
# Also maintain a request queue and an executor.
108109
if executor is None:
109-
executor = futures.ThreadPoolExecutor(max_workers=10)
110+
executor_kwargs = {}
111+
if sys.version_info >= (3, 6):
112+
executor_kwargs['thread_name_prefix'] = (
113+
'ThreadPoolExecutor-SubscriberPolicy')
114+
executor = futures.ThreadPoolExecutor(
115+
max_workers=10,
116+
**executor_kwargs
117+
)
110118
self._executor = executor
111119
_LOGGER.debug('Creating callback requests thread (not starting).')
112120
self._callback_requests = _helper_threads.QueueCallbackThread(

0 commit comments

Comments
 (0)