Python3.6 не может рассолить _треад.Объекты RLock

#python-3.x

Вопрос:

Когда я запускаю команду fab, я получил ошибку ниже, я не могу выполнить ни одну задачу fab, даже если это простая задача печати. Ошибка при разборе-задача:

 17:00:41  Traceback (most recent call last):
17:00:41    File "/bin/fab", line 8, in <module>
17:00:41      sys.exit(program.run())
17:00:41    File "/lib64/python3.6/site-packages/invoke/program.py", line 375, in run
17:00:41      self.parse_tasks()
17:00:41    File "/lib64/python3.6/site-packages/invoke/program.py", line 739, in parse_tasks
17:00:41      result = self.parser.parse_argv(self.core.unparsed)
17:00:41    File "/lib64/python3.6/site-packages/invoke/parser/parser.py", line 87, in parse_argv
17:00:41      ignore_unknown=self.ignore_unknown,
17:00:41    File "/lib64/python3.6/site-packages/invoke/parser/parser.py", line 208, in __init__
17:00:41      self.contexts = copy.deepcopy(contexts)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 180, in deepcopy
17:00:41      y = _reconstruct(x, memo, *rv)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 306, in _reconstruct
17:00:41      value = deepcopy(value, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 180, in deepcopy
17:00:41      y = _reconstruct(x, memo, *rv)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 280, in _reconstruct
17:00:41      state = deepcopy(state, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 150, in deepcopy
17:00:41      y = copier(x, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 240, in _deepcopy_dict
17:00:41      y[deepcopy(key, memo)] = deepcopy(value, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 180, in deepcopy
17:00:41      y = _reconstruct(x, memo, *rv)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 306, in _reconstruct
17:00:41      value = deepcopy(value, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 180, in deepcopy
17:00:41      y = _reconstruct(x, memo, *rv)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 280, in _reconstruct
17:00:41      state = deepcopy(state, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 150, in deepcopy
17:00:41      y = copier(x, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 240, in _deepcopy_dict
17:00:41      y[deepcopy(key, memo)] = deepcopy(value, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 180, in deepcopy
17:00:41      y = _reconstruct(x, memo, *rv)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 280, in _reconstruct
17:00:41      state = deepcopy(state, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 150, in deepcopy
17:00:41      y = copier(x, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 240, in _deepcopy_dict
17:00:41      y[deepcopy(key, memo)] = deepcopy(value, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 180, in deepcopy
17:00:41      y = _reconstruct(x, memo, *rv)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 280, in _reconstruct
17:00:41      state = deepcopy(state, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 150, in deepcopy
17:00:41      y = copier(x, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 240, in _deepcopy_dict
17:00:41      y[deepcopy(key, memo)] = deepcopy(value, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 150, in deepcopy
17:00:41      y = copier(x, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 215, in _deepcopy_list
17:00:41      append(deepcopy(a, memo))
17:00:41    File "/usr/lib64/python3.6/copy.py", line 180, in deepcopy
17:00:41      y = _reconstruct(x, memo, *rv)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 280, in _reconstruct
17:00:41      state = deepcopy(state, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 150, in deepcopy
17:00:41      y = copier(x, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 240, in _deepcopy_dict
17:00:41      y[deepcopy(key, memo)] = deepcopy(value, memo)
17:00:41    File "/usr/lib64/python3.6/copy.py", line 169, in deepcopy
17:00:41      rv = reductor(4)
17:00:41  TypeError: can't pickle _thread.RLock objects
 

Фрагменты моего фабфайла. Я подозреваю, что это связано с классом инициализации.

Ниже приведен внутренний класс для загрузки данных из файлов. как часть инициализации. Нет многопоточности.

 class All_Slave_Data(object):  
    all_loaded_slave_data = {}

    def __init__(self, directory='.'):
        # Make this the default logger
        log = _globallog

        self.initialized = False
        # Load from multiple files.
        fileCount = 0

        # Do not descend into subdirectories
        filenames = [f for f in glob.glob(os.path.join(_basepath, 'slaves_*.yaml'))]
        for filename in filenames:
            <some file operations>
            self.all_loaded_slave_data.update(partial_data)


    def getData(self):
        if not self.all_loaded_slave_data:
            self.__init__()
        return self.all_loaded_slave_data


_allSlaveData = All_Slave_Data()
_the_slave_data = _allSlaveData.getData()



 

ниже приведена простая задача, я пробовал, на самом деле я не могу выполнить ни одной задачи.

 @task  
def export_master_data(c, directory='.', log=_globallog):
   <some simple actions, from the error log, it did not touch the task body>
 

Я мог бы успешно выполнить ту же команду fab в python3.8.2.

Если у вас есть какие-либо подсказки или решения, мы будем очень признательны!

Ответ №1:

Утверждено, что это проблема с Python3.6.Проблема не существует в Python3. 7 и Python3.8.