首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将gremlinpython client.submitAsync()部署到Azure作为应用程序服务时失败

将gremlinpython client.submitAsync()部署到Azure作为应用程序服务时失败
EN

Stack Overflow用户
提问于 2021-11-12 21:14:45
回答 2查看 305关注 0票数 1

我有一个Python应用程序,我可以在本地运行。我已经能够用python3.8和3.9运行它。在本地运行时,应用程序可以使用gremlin API连接到Cosmos DB的本地实例,以及托管在Microsoft上的实例。当我或同事将Flask应用程序部署为Azure Azure (python 3.8.6)时,在尝试查询cosmos DB时会出现错误。堆栈跟踪和代码如下。我不知道为什么

TypeError:init()缺少一个必需的位置参数:'max_workers‘

因为ThreadPoolExecutor的所有参数都有默认参数。我试图在初始化gremlin客户机时指定工作人员,但这并没有什么区别。看起来,如果没有传入值,客户端将默认许多工作人员。当我在Azure上跑步时,我也指定了枪手的工作人员,但这并没有什么区别。在本地开发时,我在Windows上运行,而App在部署到Azure时运行在Linux上。这个水瓶座的应用程序确实启动良好,我可以点击其他烧瓶端点,不查询宇宙。

工人=4应用程序:app

堆栈跟踪:

代码语言:javascript
复制
  File "/tmp/8d9a55045f9e6ed/myApp/grem.py", line xxxx, in __init__
    res = self.call_graph(gremlin_query)
  File "/tmp/8d9a55045f9e6ed/myApp/grem.py", line xxxx, in call_graph
    callback = self.client.submitAsync(query)
  File "/tmp/8d9a55045f9e6ed/antenv/lib/python3.8/site-packages/gremlin_python/driver/client.py", line 144, in submitAsync
    return conn.write(message)
  File "/tmp/8d9a55045f9e6ed/antenv/lib/python3.8/site-packages/gremlin_python/driver/connection.py", line 55, in write
    self.connect()
  File "/tmp/8d9a55045f9e6ed/antenv/lib/python3.8/site-packages/gremlin_python/driver/connection.py", line 45, in connect
    self._transport.connect(self._url, self._headers)
  File "/tmp/8d9a55045f9e6ed/antenv/lib/python3.8/site-packages/gremlin_python/driver/aiohttp/transport.py", line 77, in connect
    self._loop.run_until_complete(async_connect())
  File "/opt/python/3.8.6/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/tmp/8d9a55045f9e6ed/antenv/lib/python3.8/site-packages/gremlin_python/driver/aiohttp/transport.py", line 67, in async_connect
    self._websocket = await self._client_session.ws_connect(url, **self._aiohttp_kwargs, headers=headers)
  File "/tmp/8d9a55045f9e6ed/antenv/lib/python3.8/site-packages/aiohttp/client.py", line 754, in _ws_connect
    resp = await self.request(
  File "/tmp/8d9a55045f9e6ed/antenv/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request
    conn = await self._connector.connect(
  File "/tmp/8d9a55045f9e6ed/antenv/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/tmp/8d9a55045f9e6ed/antenv/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/tmp/8d9a55045f9e6ed/antenv/lib/python3.8/site-packages/aiohttp/connector.py", line 999, in _create_direct_connection
    hosts = await asyncio.shield(host_resolved)
  File "/tmp/8d9a55045f9e6ed/antenv/lib/python3.8/site-packages/aiohttp/connector.py", line 865, in _resolve_host
    addrs = await self._resolver.resolve(host, port, family=self._family)
  File "/tmp/8d9a55045f9e6ed/antenv/lib/python3.8/site-packages/aiohttp/resolver.py", line 31, in resolve
    infos = await self._loop.getaddrinfo(
  File "/opt/python/3.8.6/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
    return await self.run_in_executor(
  File "/opt/python/3.8.6/lib/python3.8/asyncio/base_events.py", line 780, in run_in_executor
    executor = concurrent.futures.ThreadPoolExecutor()
TypeError: __init__() missing 1 required positional argument: 'max_workers'

requirements.txt

代码语言:javascript
复制
Flask
Flask-SQLAlchemy
Flask-WTF
Flask-APScheduler
python-dateutil
azure-storage-file-share
gremlinpython
openpyxl
python-dotenv
python-logstash-async
futures

Gremlin客户端初始化

代码语言:javascript
复制
    self.client = client.Client(end_point,
                                'g',
                                username=username,
                                password=password,
                                message_serializer=serializer.GraphSONSerializersV2d0()
                                )

将查询发送到Gremlin,这一行将导致异常。

代码语言:javascript
复制
callback = self.client.submitAsync(query)
EN

回答 2

Stack Overflow用户

发布于 2021-11-13 05:24:41

我通过对本地代码执行requirements.txt来创建一个新的pip freeze > requirements.txt,从而解决了这个问题。然后,我用更新的文件部署我的应用程序。我在想,azure可能为我提供了一个与python 3.8.6不兼容的不同版本的aiohttp,但我不确定。在任何情况下,提供所有这些依赖定义都会使我感到困惑。希望这能帮到其他人。

代码语言:javascript
复制
aenum==2.2.6
aiohttp==3.7.4
APScheduler==3.8.0
async-timeout==3.0.1
attrs==21.2.0
azure-core==1.16.0
azure-cosmos==4.2.0
azure-functions==1.7.2
azure-storage-blob==12.8.1
azure-storage-file-share==12.5.0
certifi==2021.5.30
cffi==1.14.6
chardet==3.0.4
click==8.0.1
colorama==0.4.4
cryptography==3.4.7
et-xmlfile==1.1.0
Flask==1.1.2
Flask-APScheduler==1.12.2
gremlinpython==3.5.1
idna==2.10
isodate==0.6.0
itsdangerous==2.0.1
Jinja2==3.0.1
limits==1.5.1
MarkupSafe==2.0.1
msrest==0.6.21
multidict==5.1.0
neo4j==4.3.2
nest-asyncio==1.5.1
oauthlib==3.1.1
openpyxl==3.0.7
pycparser==2.20
pylogbeat==2.0.0
pyparsing==2.4.7
python-dateutil==2.8.2
python-dotenv==0.19.0
python-logstash-async==2.3.0
pytz==2021.1
PyYAML==5.4.1
requests==2.25.1
requests-oauthlib==1.3.0
six==1.16.0
tornado==6.1
typing-extensions==3.10.0.0
tzlocal==2.1
urllib3==1.26.6
Werkzeug==2.0.1
yarl==1.6.3
票数 2
EN

Stack Overflow用户

发布于 2022-10-04 16:44:39

请注意,client.submitAsync(查询)已更改为client.submit_async,请参见https://github.com/apache/tinkerpop/blob/master/gremlin-python/src/main/python/gremlin_python/driver/client.py

代码语言:javascript
复制
 def submitAsync(self, message, bindings=None, request_options=None):
    warnings.warn(
        "gremlin_python.driver.client.Client.submitAsync will be replaced by "
        "gremlin_python.driver.client.Client.submit_async.",
        DeprecationWarning)
    return self.submit_async(message, bindings, request_options)

def submit_async(self, message, bindings=None, request_options=None):
    ...
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69949132

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档