vinx13 commented on a change in pull request #8492:
URL: https://github.com/apache/tvm/pull/8492#discussion_r675212877



##########
File path: python/tvm/auto_scheduler/utils.py
##########
@@ -314,6 +314,8 @@ def call_func_with_timeout(timeout, func, args=(), 
kwargs=None, add_thread_wrapp
     except Exception as ex:
         res = ex
 
+    process.kill()

Review comment:
       this is not needed as it is called in `POpenWorker.__del__`

##########
File path: python/tvm/auto_scheduler/utils.py
##########
@@ -306,6 +307,7 @@ def _func_wrapper(que, func, args, kwargs, 
add_thread_wrapper):
 def call_func_with_timeout(timeout, func, args=(), kwargs=None, 
add_thread_wrapper=False):
     """Call a function with timeout"""
     que = multiprocessing.Queue(2)
+    process = PopenWorker()

Review comment:
       argument `add_thread_wrapper` can be removed, it uses `popen` to create 
a new process which won't cause conflict with tvm thread pool. cc @merrymercy 
@jcf94

##########
File path: python/tvm/auto_scheduler/utils.py
##########
@@ -305,25 +306,15 @@ def _func_wrapper(que, func, args, kwargs, 
add_thread_wrapper):
 
 def call_func_with_timeout(timeout, func, args=(), kwargs=None, 
add_thread_wrapper=False):
     """Call a function with timeout"""
-    que = multiprocessing.Queue(2)
-    process = multiprocessing.Process(
-        target=_func_wrapper, args=(que, func, args, kwargs or {}, 
add_thread_wrapper)
-    )
-    process.start()
+    process = PopenWorker()
+    process.send(func, args, kwargs, timeout)
 
     try:
-        res = que.get(timeout=timeout)
-    except queue.Empty:
-        res = TimeoutError()
-
-    # clean queue and process
-    kill_child_processes(process.pid)
-    process.terminate()
-    process.join()
-    que.close()
-    que.join_thread()
-    del process
-    del que
+        res = process.recv()
+    except Exception as ex:
+        res = ex

Review comment:
       we'd still like to use `make_traceback_info` to make sure the exception 
has the same format




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to