@@ -87,16 +87,19 @@ def _client_worker_process(factory, input_queue, output_queue, is_shutdown):
8787 :param output_queue: The queue to place client responses
8888 :param is_shutdown: Condition variable marking process shutdown
8989 """
90- log .info ("starting up worker : %s" , threading .current_thread ())
90+ txt = f"starting up worker : { threading .current_thread ()} "
91+ log .info (txt )
9192 my_client = factory ()
9293 while not is_shutdown .is_set ():
9394 try :
9495 workitem = input_queue .get (timeout = 1 )
95- log .debug ("dequeue worker request: %s" , workitem )
96+ txt = f"dequeue worker request: { workitem } "
97+ log .debug (txt )
9698 if not workitem :
9799 continue
98100 try :
99- log .debug ("executing request on thread: %s" , workitem )
101+ txt = f"executing request on thread: { workitem } "
102+ log .debug (txt )
100103 result = my_client .execute (workitem .request )
101104 output_queue .put (WorkResponse (False , workitem .work_id , result ))
102105 except Exception as exc : # pylint: disable=broad-except
@@ -106,7 +109,8 @@ def _client_worker_process(factory, input_queue, output_queue, is_shutdown):
106109 workitem .work_id , exc ))
107110 except Exception : # nosec pylint: disable=broad-except
108111 pass
109- log .info ("request worker shutting down: %s" , threading .current_thread ())
112+ txt = f"request worker shutting down: { threading .current_thread ()} "
113+ log .info (txt )
110114
111115
112116def _manager_worker_process (output_queue , my_futures , is_shutdown ):
@@ -124,12 +128,14 @@ def _manager_worker_process(output_queue, my_futures, is_shutdown):
124128 :param futures: The mapping of tid -> future
125129 :param is_shutdown: Condition variable marking process shutdown
126130 """
127- log .info ("starting up manager worker: %s" , threading .current_thread ())
131+ txt = f"starting up manager worker: { threading .current_thread ()} "
132+ log .info (txt )
128133 while not is_shutdown .is_set ():
129134 try :
130135 workitem = output_queue .get ()
131136 my_future = my_futures .get (workitem .work_id , None )
132- log .debug ("dequeue manager response: %s" , workitem )
137+ txt = f"dequeue manager response: { workitem } "
138+ log .debug (txt )
133139 if not my_future :
134140 continue
135141 if workitem .is_exception :
@@ -227,7 +233,8 @@ def execute_silently(self, request):
227233
228234 def client_factory ():
229235 """Client factory."""
230- log .debug ("creating client for: %s" , threading .current_thread ())
236+ txt = f"creating client for: { threading .current_thread ()} "
237+ log .debug (txt )
231238 my_client = ModbusTcpClient ('127.0.0.1' , port = 5020 )
232239 my_client .connect ()
233240 return client
@@ -238,6 +245,7 @@ def client_factory():
238245 futures = [client .read_coils (i * 8 , 8 ) for i in range (10 )]
239246 log .info ("waiting on futures to complete" )
240247 for future in futures :
241- log .info ("future result: %s" , future .result (timeout = 1 ))
248+ txt = f"future result: { future .result (timeout = 1 )} "
249+ log .info (txt )
242250 finally :
243251 client .shutdown ()
0 commit comments