Python 多处理在最后被卡住了

Python 多处理在最后被卡住了,python,google-oauth,Python,Google Oauth,我写了一个脚本,将一千张图片上传到谷歌硬盘,谷歌硬盘将通过OCR返回文本。为了加快流程,采用了如下多处理: from googleapiclient.discovery import build from httplib2 import Http from oauth2client import file, client, tools from googleapiclient.http import MediaFileUpload, MediaIoBaseDownload import os,

我写了一个脚本,将一千张图片上传到谷歌硬盘,谷歌硬盘将通过OCR返回文本。为了加快流程,采用了如下多处理:

from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
from googleapiclient.http import MediaFileUpload, MediaIoBaseDownload
import os, io
from multiprocessing import Pool
from functools import partial

SCOPES = 'https://www.googleapis.com/auth/drive'


def authorize_api():
    store = file.Storage('token.json')
    creds = store.get()
    if not creds or creds.invalid:
        flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
        creds = tools.run_flow(flow, store)
    return build('drive', 'v3', http=creds.authorize(Http()))

def main(IMAGEDIR,upscale):
    drive_service = authorize_api()
    print('[%s]' % upscale)
    print('Uploading... ', end='', flush=True)
    file_metadata = {'name': upscale, 'mimeType': 'application/vnd.google-apps.document'}
    full_path = os.path.join(IMAGEDIR, upscale)
    media = MediaFileUpload(full_path, mimetype='image/jpeg', resumable=True)
    file = drive_service.files().create(body=file_metadata, media_body=media, fields='id').execute()
    file_id = file.get('id')
    print('Done')
    #print('File ID: %s' % file_id)

    print('Downloading... ', end='', flush=True)
    output_upscale = os.path.splitext(upscale)[0] + '.txt'
    output_upscale = os.path.join('TXTResults', output_upscale)
    fh = io.FileIO(output_upscale, 'wb')
    request = drive_service.files().export_media(fileId=file_id, mimeType='text/plain')
    downloader = MediaIoBaseDownload(fh, request)
    done = False
    while done is False:
        status, done = downloader.next_chunk()
    print('Done')

    drive_service.files().delete(fileId=file_id).execute()


if __name__ == '__main__':
    upscale=[]
    IMAGEDIR = 'upscale'
    for filename in os.listdir(IMAGEDIR):
        upscale.append(filename)
        
    pool = Pool()
    func = partial(main, IMAGEDIR)
    pool.map(func, upscale)
但最后一个过程被卡住了。它导致.txt的数量少于图像的数量。任何帮助都将不胜感激