moh*_*eem 5 python google-api python-3.x google-drive-api concurrent.futures
当尝试使用并发.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)
Run Code Online (Sandbox Code Playgroud)
malloc():未排序的双链表损坏中止(核心转储)
该脚本执行速度很快(2 秒内),并且只创建垃圾文件(大小为 0 字节的文件)。但是我能够同步下载文件而不会出现任何中断。
小智 1
我也遇到了这个问题。我正在使用 google 目录 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()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3603 次 |
| 最近记录: |