いくつかの分散ベンチマークを実行するために、並列 python を使用しようとしています (基本的に、中央サーバーから一連のマシンでいくつかのコードを調整して実行します)。機能を別のパッケージに移動するまで、私が持っていたコードは完全に正常に機能していました。それ以来、私は取得し続けImportError: No module named some.module.pp_test
ます。
私の質問は実際には 2 つあります。誰かが でこの問題に遭遇したpp
ことがありますか?もしそうなら、どうすれば解決できますか? dill
( )を使用してみimport dill
ましたが、役に立ちませんでした。また、追加のインフラストラクチャを必要としない、parallelpython の適切な代替品はありますか?
私が得る正確なエラーは次のとおりです。
RUNNING TEST
Waiting for hosts to finish booting....A fatal error has occured during the function execution
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/ppworker.py", line 86, in run
__args = pickle.loads(__sargs)
ImportError: No module named some.module.pp_test
Caught exception in the run phase 'NoneType' object is not iterable
Traceback (most recent call last):
File "test.py", line 5, in <module>
p.ping_pong()
File "/home/ubuntu/workspace/pp-test/some/module/pp_test.py", line 5, in ping_pong
a_test.run()
File "/home/ubuntu/workspace/pp-test/some/module/pp_test.py", line 27, in run
pong, hostname = ping()
TypeError: 'NoneType' object is not iterable
コードは次のように構成されています。
pp-test/
test.py
some/
__init__.py
module/
__init__.py
pp_test.py
は次のtest.py
ように実装されます。
from some.module.pp_test import MWE
p = MWE()
p.ping_pong()
ながらpp_test.py
:
class MWE():
def ping_pong(self):
print "RUNNING TEST "
a_test = PPTester()
a_test.run()
import pp
import time
from sys import stdout, exit
class PPTester(object):
def run(self):
try:
ppservers = ('10.10.10.10', )
time.sleep(5)
job_server = pp.Server(0, ppservers=ppservers)
stdout.write("Waiting for hosts to finish booting...")
while len(job_server.get_active_nodes()) - 1 < len(ppservers):
stdout.write(".")
stdout.flush()
time.sleep(1)
ppmodules = ()
pings = [(server, job_server.submit(self.run_pong, modules=ppmodules)) for server in ppservers]
for server, ping in pings:
pong, hostname = ping()
print "Host ", hostname, " is alive!"
print "All servers booted up, starting benchmarks..."
job_server.print_stats()
except Exception as e:
print "Caught exception in the run phase", e
raise
pass
def run_pong(self):
import subprocess
p = subprocess.Popen("hostname", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
(output, err) = p.communicate()
p_status = p.wait()
return "pong ", output