jiangling_0103 发表于 2016-04-25 14:17

关于 fabric 并行执行任务求助

如下,我想使用 fabric 在多台机器上并行执行下面的 test_task 任务(Windows上运行该脚本),我在前面加上了 @parallel(pool_size=5) ,但是会报下面的错误,不知道是那边的问题,还请帮忙看下的,多谢


from fabric.api import *

env.hosts=[
         'builder@10.0.1.88:22',
         'builder@10.0.1.80:22',
         'builder@10.0.1.57:22',
         'builder@10.0.1.58:22',
         'builder@10.0.1.59:22',
         ]      
            
            
env.password = 'xxxxxx'

@parallel(pool_size=5)
def test_task():
   space_info = run('df -h | grep space')




报错如下:

[builder@10.0.1.88:22] Executing task 'update_setting_remote'
[builder@10.0.1.80:22] Executing task 'update_setting_remote'
[builder@10.0.1.57:22] Executing task 'update_setting_remote'
[builder@10.0.1.58:22] Executing task 'update_setting_remote'
[builder@10.0.1.59:22] Executing task 'update_setting_remote'
Traceback (most recent call last):
   File "C:\Python27\lib\site-packages\fabric\main.py", line 745, in main
   *args, **kwargs
   File "C:\Python27\lib\site-packages\fabric\tasks.py", line 412, in execute
   ran_jobs = jobs.run()
   File "C:\Python27\lib\site-packages\fabric\job_queue.py", line 137, in run
   _advance_the_queue()
   File "C:\Python27\lib\site-packages\fabric\job_queue.py", line 122, in _advance_the_queue
   job.start()
   File "C:\Python27\lib\multiprocessing\process.py", line 130, in start
   self._popen = Popen(self)
   File "C:\Python27\lib\multiprocessing\forking.py", line 277, in __init__
   dump(process_obj, to_child, HIGHEST_PROTOCOL)
   File "C:\Python27\lib\multiprocessing\forking.py", line 199, in dump
   ForkingPickler(file, protocol).dump(obj)
   File "C:\Python27\lib\pickle.py", line 224, in dump
   self.save(obj)
   File "C:\Python27\lib\pickle.py", line 331, in save
   self.save_reduce(obj=obj, *rv)
   File "C:\Python27\lib\pickle.py", line 419, in save_reduce
   save(state)
   File "C:\Python27\lib\pickle.py", line 286, in save
   f(self, obj) # Call unbound method with explicit self
   File "C:\Python27\lib\pickle.py", line 649, in save_dict
   self._batch_setitems(obj.iteritems())
   File "C:\Python27\lib\pickle.py", line 681, in _batch_setitems
   save(v)
   File "C:\Python27\lib\pickle.py", line 286, in save
   f(self, obj) # Call unbound method with explicit self
   File "C:\Python27\lib\pickle.py", line 748, in save_global
   (obj, module, name))
pickle.PicklingError: Can't pickle <function inner at 0x01FDD1F0>: it's not found as fabric.tasks.inner
Traceback (most recent call last):
   File "<string>", line 1, in <module>
   File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
   prepare(preparation_data)
   File "C:\Python27\lib\multiprocessing\forking.py", line 488, in prepare
   assert main_name not in sys.modules, main_name
AssertionError: __main__

jiangling_0103 发表于 2016-04-25 15:14

查了下,windows下运行的已知问题。。。。
页: [1]
查看完整版本: 关于 fabric 并行执行任务求助