@@ -207,19 +207,6 @@ def result(self, timeout=None):
207207 raise RemoteException (self ._exception .msg , self ._exception .exc )
208208 return self ._result
209209
210- @staticmethod
211- def _qcomm_main (comm , main , * args , ** kwargs ):
212- """Main routine -- handles return values and exceptions."""
213- try :
214- if not kwargs .get ("user_function" ):
215- _result = main (comm , * args , ** kwargs )
216- else :
217- _result = main (* args )
218- comm .send (CommResult (_result ))
219- except Exception as e :
220- comm .send (CommResultErr (str (e ), format_exc ()))
221- raise e
222-
223210 @property
224211 def running (self ):
225212 """Check if the thread/process is running."""
@@ -233,6 +220,19 @@ def __exit__(self, etype, value, traceback):
233220 self .handle .join ()
234221
235222
223+ def _qcomm_main (comm , main , * args , ** kwargs ):
224+ """Main routine -- handles return values and exceptions."""
225+ try :
226+ if not kwargs .get ("user_function" ):
227+ _result = main (comm , * args , ** kwargs )
228+ else :
229+ _result = main (* args )
230+ comm .send (CommResult (_result ))
231+ except Exception as e :
232+ comm .send (CommResultErr (str (e ), format_exc ()))
233+ raise e
234+
235+
236236class QCommThread (QCommLocal ):
237237 """Launch a user function in a thread with an attached QComm."""
238238
@@ -241,7 +241,7 @@ def __init__(self, main, nworkers, *args, **kwargs):
241241 self .outbox = thread_queue .Queue ()
242242 super ().__init__ (self , main , * args , ** kwargs )
243243 comm = QComm (self .inbox , self .outbox , nworkers )
244- self .handle = Thread (target = QCommThread . _qcomm_main , args = (comm , main ) + args , kwargs = kwargs )
244+ self .handle = Thread (target = _qcomm_main , args = (comm , main ) + args , kwargs = kwargs )
245245
246246 def terminate (self , timeout = None ):
247247 """Terminate the thread.
@@ -265,7 +265,7 @@ def __init__(self, main, nworkers, *args, **kwargs):
265265 self .outbox = Queue ()
266266 super ().__init__ (self , main , * args , ** kwargs )
267267 comm = QComm (self .inbox , self .outbox , nworkers )
268- self .handle = Process (target = QCommProcess . _qcomm_main , args = (comm , main ) + args , kwargs = kwargs )
268+ self .handle = Process (target = _qcomm_main , args = (comm , main ) + args , kwargs = kwargs )
269269
270270 def terminate (self , timeout = None ):
271271 """Terminate the process."""
0 commit comments