From 6ac11e00a6169e39519d316226e59f8147471104 Mon Sep 17 00:00:00 2001
From: Shenghang Tsai <jackalcooper@gmail.com>
Date: Mon, 19 Jul 2021 20:34:08 +0800
Subject: [PATCH] prevent endless loop (#5534)

* prevent endless loop

* add timeout 2 hours to prevent exhaust machine

Co-authored-by: oneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com>
---
 .github/workflows/simple.yml             | 1 +
 tools/conver_single_client_name_space.py | 9 +++++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/simple.yml b/.github/workflows/simple.yml
index 18fd4d1c6..939893354 100644
--- a/.github/workflows/simple.yml
+++ b/.github/workflows/simple.yml
@@ -27,6 +27,7 @@ jobs:
     if: github.ref == 'refs/heads/master' || (github.event.pull_request.draft == false && contains(github.event.pull_request.requested_reviewers.*.login, 'oneflow-ci-bot'))
     runs-on: ${{ matrix.os }}
     needs: [cancel_previous]
+    timeout-minutes: 120
     strategy:
       fail-fast: false
       max-parallel: 3
diff --git a/tools/conver_single_client_name_space.py b/tools/conver_single_client_name_space.py
index 8770a7bd1..9755c913e 100644
--- a/tools/conver_single_client_name_space.py
+++ b/tools/conver_single_client_name_space.py
@@ -23,7 +23,8 @@ def convert_name_sapce(python_file):
     )
 
 
-with multiprocessing.Pool(processes=multiprocessing.cpu_count()) as pool:
-    pool.map(convert_name_sapce, single_client_python_files)
-    pool.close()
-    pool.join()
+if __name__ == "__main__":
+    with multiprocessing.Pool(processes=multiprocessing.cpu_count()) as pool:
+        pool.map(convert_name_sapce, single_client_python_files)
+        pool.close()
+        pool.join()
-- 
GitLab