Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在单独的python线程中上载到Google Drive_Python_Docker_Flask_Google Drive Api_Python Multithreading - Fatal编程技术网

在单独的python线程中上载到Google Drive

在单独的python线程中上载到Google Drive,python,docker,flask,google-drive-api,python-multithreading,Python,Docker,Flask,Google Drive Api,Python Multithreading,我遇到了一个问题,在一个单独的线程中用Python 3.6上传到Google Drive似乎仍然阻塞了我的主线程 我正在运行一个flask服务器(在docker容器中),该服务器根据请求启动一个单独的线程,该线程首先下载一个文件,然后将其上传到Google Drive。除此之外,基本上是这样的: @app.route(“/work”) 定义工作(): thread=thread(target=handle,args=request.args.to_dict()) thread.start() 返

我遇到了一个问题,在一个单独的线程中用Python 3.6上传到Google Drive似乎仍然阻塞了我的主线程

我正在运行一个
flask
服务器(在docker容器中),该服务器根据请求启动一个单独的线程,该线程首先下载一个文件,然后将其上传到Google Drive。除此之外,基本上是这样的:

@app.route(“/work”)
定义工作():
thread=thread(target=handle,args=request.args.to_dict())
thread.start()
返回“工作”
def句柄(args):
filename=下载\u文件(args)
上传到驱动器(文件名)
def上传到驱动器(文件名):
media=MediaFileUpload(文件名,mimetype=property_mimetype(文件名))
drive=googleapiclient.discovery.build('drive','v3',credentials=CREDS)
上传的文件\u id=drive.files()。创建(
正文={'name':文件名},
媒体体=媒体,
fields='id'
).execute()
返回上载的\u文件\u id
服务器启动线程并响应请求后,向服务器发送的任何其他请求都可以正常服务,但仅在服务器下载时(
download\u)该文件使用
requests.get(…,stream=True)。iter\u content()
。但是,当上传到Google Drive开始时,任何新请求都会挂起,直到上传完成

知道原因吗?我能做些什么来保持服务器响应