Google Celery 中的驱动器 API 任务失败
Google Drive API in Celery Task is Failing
最新更新:http
任务中的请求正在运行但未运行 https
。
我正在尝试使用 Celery Task 将文件上传到 Google 驱动器,一旦文件已上传到本地 Web 服务器以进行备份。
我看到多个问题问类似的事情。我不能让 Google API 在 celery 任务中工作但是当我 运行 它没有 delay()
时它工作。问题没有收到任何答案。
Question 1 @chucky 和我一样挣扎。
实施和信息:
- 服务器:Django 开发服务器(本地主机)
- Celery:使用 RabbitMQ
- 数据库:Postgres
- Google驱动器API:V3
I was able to get credentials and token for accessing drive files and
display first ten files,If the quickstart file is run separately.
Google Drive API Quickstart.py
运行此Quickstart.py
显示驱动器的文件和文件夹列表。
So I added the same code with all included imports in tasks.py
task
name create_upload_folder()
to test whether task will work and show
list of files.
我正在 运行 通过 Ajax 调用它,但我一直收到此错误。
所以回溯显示出现上述错误的原因是:
错误的根源是:
[2021-07-13 21:10:03,979: WARNING/MainProcess]
[2021-07-13 21:10:04,052: ERROR/MainProcess] Task create_upload_folder[2463ad5b-4c7c-4eba-b862-9417c01e8314] raised unexpected: ServerNotFoundError('Unable to find the server at www.googleapis.com')
Traceback (most recent call last):
File "f:\repos\vuetransfer\vuenv\lib\site-packages\httplib2\__init__.py", line 1346, in _conn_request
conn.connect()
File "f:\repos\vuetransfer\vuenv\lib\site-packages\httplib2\__init__.py", line 1136, in connect
sock.connect((self.host, self.port))
File "f:\repos\vuetransfer\vuenv\lib\site-packages\eventlet\greenio\base.py", line 257, in connect
if socket_connect(fd, address):
File "f:\repos\vuetransfer\vuenv\lib\site-packages\eventlet\greenio\base.py", line 40, in socket_connect
err = descriptor.connect_ex(address)
名称解析失败(无法找到 www.googleapis.com
的 IP),因为它很可能无法联系具有该 IP 的 DNS 服务器(或无法联系 任何 DNS服务器)。
确保您的 DNS 服务器设置正确,或者如果您在公司 proxy/VPN 的支持下使用它。
您可以通过手动获取 IP 来验证它是否正常工作:
nslookup www.googleapis.com
$ nslookup www.googleapis.com
Non-authoritative answer:
Name: www.googleapis.com
Address: 172.217.23.234
Name: www.googleapis.com
Address: 216.58.201.74
Name: www.googleapis.com
Address: 172.217.23.202
Name: www.googleapis.com
Address: 2a00:1450:4014:80c::200a
Name: www.googleapis.com
Address: 2a00:1450:4014:800::200a
Name: www.googleapis.com
Address: 2a00:1450:4014:80d::200a
如果您可以手动获取 IP,则存在连接问题 Python 本身并不知道代理(可能已在您的 PC 上设置),为此请尝试使用:
http_proxy=http://your.proxy:port
https_proxy=http://your.proxy:port
在环境中或作为命令前缀或直接在 HTTP 客户端配置中 httplib2
使用。
主要问题是将 httplib2 与 python3 或其他一些并发症一起使用,即使 google_client_api 对于 python 说它得到完全支持 你在 requests.Atleast 上遇到了一些问题Windows 上的 python3 对我来说是个问题。
经过大量研究,我发现回退到 python2 是一种解决方案,但另一个可以在为您的服务创建凭据之后和 [=12= 之前使用 httplib2shim
]您的服务需要拨打
.
.
httplib2shim.patch()
service = build(API_SERVICE_NAME, API_VERSION, credentials=creds)
这将解决 httplib2 无法找到 www.googleapis.com
的问题
最新更新:http
任务中的请求正在运行但未运行 https
。
我正在尝试使用 Celery Task 将文件上传到 Google 驱动器,一旦文件已上传到本地 Web 服务器以进行备份。
我看到多个问题问类似的事情。我不能让 Google API 在 celery 任务中工作但是当我 运行 它没有 delay()
时它工作。问题没有收到任何答案。
Question 1 @chucky 和我一样挣扎。
实施和信息:
- 服务器:Django 开发服务器(本地主机)
- Celery:使用 RabbitMQ
- 数据库:Postgres
- Google驱动器API:V3
I was able to get credentials and token for accessing drive files and display first ten files,If the quickstart file is run separately. Google Drive API Quickstart.py
运行此Quickstart.py
显示驱动器的文件和文件夹列表。
So I added the same code with all included imports in
tasks.py
task namecreate_upload_folder()
to test whether task will work and show list of files.
我正在 运行 通过 Ajax 调用它,但我一直收到此错误。
所以回溯显示出现上述错误的原因是:
错误的根源是:
[2021-07-13 21:10:03,979: WARNING/MainProcess]
[2021-07-13 21:10:04,052: ERROR/MainProcess] Task create_upload_folder[2463ad5b-4c7c-4eba-b862-9417c01e8314] raised unexpected: ServerNotFoundError('Unable to find the server at www.googleapis.com')
Traceback (most recent call last):
File "f:\repos\vuetransfer\vuenv\lib\site-packages\httplib2\__init__.py", line 1346, in _conn_request
conn.connect()
File "f:\repos\vuetransfer\vuenv\lib\site-packages\httplib2\__init__.py", line 1136, in connect
sock.connect((self.host, self.port))
File "f:\repos\vuetransfer\vuenv\lib\site-packages\eventlet\greenio\base.py", line 257, in connect
if socket_connect(fd, address):
File "f:\repos\vuetransfer\vuenv\lib\site-packages\eventlet\greenio\base.py", line 40, in socket_connect
err = descriptor.connect_ex(address)
名称解析失败(无法找到 www.googleapis.com
的 IP),因为它很可能无法联系具有该 IP 的 DNS 服务器(或无法联系 任何 DNS服务器)。
确保您的 DNS 服务器设置正确,或者如果您在公司 proxy/VPN 的支持下使用它。
您可以通过手动获取 IP 来验证它是否正常工作:
nslookup www.googleapis.com
$ nslookup www.googleapis.com
Non-authoritative answer:
Name: www.googleapis.com
Address: 172.217.23.234
Name: www.googleapis.com
Address: 216.58.201.74
Name: www.googleapis.com
Address: 172.217.23.202
Name: www.googleapis.com
Address: 2a00:1450:4014:80c::200a
Name: www.googleapis.com
Address: 2a00:1450:4014:800::200a
Name: www.googleapis.com
Address: 2a00:1450:4014:80d::200a
如果您可以手动获取 IP,则存在连接问题 Python 本身并不知道代理(可能已在您的 PC 上设置),为此请尝试使用:
http_proxy=http://your.proxy:port
https_proxy=http://your.proxy:port
在环境中或作为命令前缀或直接在 HTTP 客户端配置中 httplib2
使用。
主要问题是将 httplib2 与 python3 或其他一些并发症一起使用,即使 google_client_api 对于 python 说它得到完全支持 你在 requests.Atleast 上遇到了一些问题Windows 上的 python3 对我来说是个问题。
经过大量研究,我发现回退到 python2 是一种解决方案,但另一个可以在为您的服务创建凭据之后和 [=12= 之前使用 httplib2shim
]您的服务需要拨打
.
.
httplib2shim.patch()
service = build(API_SERVICE_NAME, API_VERSION, credentials=creds)
这将解决 httplib2 无法找到 www.googleapis.com