From 2ceb981da0cfe56cddbd421d673e4b35d1b7b53a Mon Sep 17 00:00:00 2001 From: Linker Lin Date: Sun, 28 Jul 2013 00:07:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=A3=80=E6=B5=8BCPU?= =?UTF-8?q?=E6=95=B0=E7=9B=AE=EF=BC=8C=E5=90=AF=E5=8A=A8=E5=90=88=E9=80=82?= =?UTF-8?q?=E6=95=B0=E7=9B=AE=E7=9A=84=E8=BF=9B=E7=A8=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/parallel/test_file.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parallel/test_file.py b/test/parallel/test_file.py index 8372596..0a5f0fe 100644 --- a/test/parallel/test_file.py +++ b/test/parallel/test_file.py @@ -3,7 +3,8 @@ import sys,time import sys sys.path.append("../../") import jieba -jieba.enable_parallel(4) +import multiprocessing +jieba.enable_parallel(multiprocessing.cpu_count()) url = sys.argv[1] content = open(url,"rb").read() From 1dbc525dfff9bbae106015fcfb9ed8c388149d01 Mon Sep 17 00:00:00 2001 From: Linker Lin Date: Sun, 28 Jul 2013 00:10:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=A3=80=E6=B5=8BCPU?= =?UTF-8?q?=E6=95=B0=E7=9B=AE=EF=BC=8C=E5=90=AF=E5=8A=A8=E5=90=88=E9=80=82?= =?UTF-8?q?=E6=95=B0=E7=9B=AE=E7=9A=84=E8=BF=9B=E7=A8=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jieba/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jieba/__init__.py b/jieba/__init__.py index 0ee4320..ac5f61f 100644 --- a/jieba/__init__.py +++ b/jieba/__init__.py @@ -292,8 +292,10 @@ def __lcut_all(sentence): def __lcut_for_search(sentence): return list(__ref_cut_for_search(sentence)) +import multiprocessing + @require_initialized -def enable_parallel(processnum): +def enable_parallel(processnum=multiprocessing.cpu_count()): global pool,cut,cut_for_search if os.name=='nt': raise Exception("jieba: parallel mode only supports posix system") From 5d8385508877fb5831ef4478c3053450d0a12c72 Mon Sep 17 00:00:00 2001 From: Linker Lin Date: Sun, 28 Jul 2013 00:12:00 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=A3=80=E6=B5=8BCPU?= =?UTF-8?q?=E6=95=B0=E7=9B=AE=EF=BC=8C=E5=90=AF=E5=8A=A8=E5=90=88=E9=80=82?= =?UTF-8?q?=E6=95=B0=E7=9B=AE=E7=9A=84=E8=BF=9B=E7=A8=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/parallel/test_file.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test_file.py b/test/parallel/test_file.py index 0a5f0fe..e10d1a2 100644 --- a/test/parallel/test_file.py +++ b/test/parallel/test_file.py @@ -3,8 +3,8 @@ import sys,time import sys sys.path.append("../../") import jieba -import multiprocessing -jieba.enable_parallel(multiprocessing.cpu_count()) + +jieba.enable_parallel() url = sys.argv[1] content = open(url,"rb").read()