gpt4 book ai didi

Python 和 Nameko - GreenSSLSocket 没有公共(public)构造函数。实例由 SSLContext.wrap_socket() 返回。

转载 作者:行者123 更新时间:2023-12-01 01:44:39 34 4
gpt4 key购买 nike

我创建了一项 nameko 服务,该服务会向提供的电话号码发送短信。使用Africas Talking API 。该服务运行成功,但一旦使用 nameko shell,它就无法工作。但是,电话号码已成功传递到服务中。

滑子壳:

 >>> n.rpc.sms.text('+254712619789')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nameko/rpc.py", line 369, in __call__
return reply.result()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nameko/rpc.py", line 327, in result
raise deserialize(error)
nameko.exceptions.RemoteError: TypeError GreenSSLSocket does not have a public constructor. Instances are returned by SSLContext.wrap_socket().

滑子服务

nameko run at
starting services: sms
Connected to amqp://guest:**@127.0.0.1:5672//
+254712619789
error handling worker <WorkerContext [sms.text] at 0x10414a128>: GreenSSLSocket does not have a public constructor. Instances are returned by SSLContext.wrap_socket().
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nameko/containers.py", line 391, in _run_worker
result = method(*worker_ctx.args, **worker_ctx.kwargs)
File "./at.py", line 23, in text
response = sms.send("Hello Message!", [phone_no])
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/africastalking/SMS.py", line 32, in send
return self._make_request(url, 'POST', headers=self._headers, params=None, data=data, callback=callback)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/africastalking/Service.py", line 92, in _make_request
res = self.__make_post_request(url=url, headers=headers, data=data, params=params)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/africastalking/Service.py", line 78, in __make_post_request
data=data,
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/api.py", line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/adapters.py", line 445, in send
timeout=timeout
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
conn.connect()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connection.py", line 356, in connect
ssl_context=context)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 359, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/eventlet/green/ssl.py", line 402, in wrap_socket
return GreenSSLSocket(sock, *a, _context=self, **kw)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/eventlet/green/ssl.py", line 68, in __init__
ca_certs, do_handshake_on_connect and six.PY2, *args, **kw)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 788, in __init__
f"{self.__class__.__name__} does not have a public "
TypeError: GreenSSLSocket does not have a public constructor. Instances are returned by SSLContext.wrap_socket().

at.py

import json
from nameko.web.handlers import http
from nameko.rpc import rpc
import africastalking

class HttpService(object):
name = "sms"
@rpc
def text(self, phone_no):
print (phone_no)
africastalking.initialize(username, api_key)
# Initialize a service e.g. SMS
sms = africastalking.SMS
# Use the service synchronously
response = sms.send("Hello Message!", [phone_no])
print(response)
return response

最佳答案

问题可能是 eventlet 与 python 3.7 不兼容。你能尝试使用 python 3.6 吗?

(参见例如https://github.com/eventlet/eventlet/issues/502)

关于Python 和 Nameko - GreenSSLSocket 没有公共(public)构造函数。实例由 SSLContext.wrap_socket() 返回。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51512601/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com