【问题标题】:malloc(): unsorted double linked list corrupted Aborted (core dumped) pythonmalloc():未排序的双链表损坏中止(核心转储)python
【发布时间】:2020-11-01 12:28:21
【问题描述】:

在尝试使用 concurrent.futures 模块同时从谷歌驱动器下载文件时,下面的脚本抛出 malloc(): unsorted double linked list corrupted.

files = [
    {"id": "2131easd232", "name": "image1.jpg"},
    {"id": "2131easdfsd232", "name": "image2.jpg"},
    {"id": "2131ea32cesd232", "name": "image3.jpg"}
 ]

def download_file(data):
    request = drive_service.files().get_media(fileId=data['id'])
    fh = io.FileIO(data['name'], 'wb')
    downloader = MediaIoBaseDownload(fh, request)
    done = False
    while done is False:
        status, done = downloader.next_chunk()
    
with concurrent.futures.ThreadPoolExecutor() as executor:
    executor.map(download_file, files)

malloc(): 未排序的双链表损坏 Aborted (core dumped)

脚本快速执行(在 2 秒内)并且只创建垃圾文件(大小为 0bytes 的文件)。但是我可以同步下载文件而没有任何中断。

【问题讨论】:

    标签: python python-3.x google-api google-drive-api concurrent.futures


    【解决方案1】:

    我也遇到了这个问题。我正在使用谷歌目录 api。我认为解决这个问题的方法是在线程化的函数中创建服务对象。

    def get_user_data(useremail):
            Threadedservice = build('admin', 'directory_v1', credentials=delegated_credentials)
    
            userresults = Threadedservice.users().get(userKey=useremail, viewType='admin_view', fields='recoveryPhone, name(fullName)').execute()
    

    【讨论】:

      【解决方案2】:

      我的情况也类似,我使用的是 YouTube Data API v3。只有在线程化的函数内部或类外部和同一模块中创建服务对象时,它才有效。

      但它也可以通过使用 copy.deepcopy() 复制您的服务/资源对象并在每个线程中使用单独的复制对象来工作。

      from copy import deepcopy
      object_copy = deepcopy(object)
      

      【讨论】:

        猜你喜欢
        • 2020-01-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-12-08
        • 1970-01-01
        • 2021-12-06
        • 1970-01-01
        • 2015-09-22
        相关资源
        最近更新 更多