kombu 这套东西,到底是在哪里建立 amqp 连接的
from kombu import Connection
from kombu.pools import connections
connection = Connection('redis://localhost:6379')
with connections[connection].acquire(block=True) as conn:
print('Got connection: {0!r}'.format(connection.as_uri()))
方法:人肉看代码,手动二分,加 wireshark 抓包
在这里加了一个断言site-packages/kombu/transport/pyamqp.py
╰─➤ python 001.py
Traceback (most recent call last):
File "/Users/ponponon/Desktop/code/me/test_nameko_for_rabbitmq/001.py", line 11, in
conn.connect()
File "/Users/ponponon/.local/share/virtualenvs/test_nameko_for_rabbitmq-Kw9_vVsf/lib/python3.10/site-packages/kombu/connection.py", line 274, in connect
c=self._ensure_connection(
File "/Users/ponponon/.local/share/virtualenvs/test_nameko_for_rabbitmq-Kw9_vVsf/lib/python3.10/site-packages/kombu/connection.py", line 436, in _ensure_connection
return retry_over_time(
File "/Users/ponponon/.local/share/virtualenvs/test_nameko_for_rabbitmq-Kw9_vVsf/lib/python3.10/site-packages/kombu/utils/functional.py", line 312, in retry_over_time
return fun(*args, **kwargs)
File "/Users/ponponon/.local/share/virtualenvs/test_nameko_for_rabbitmq-Kw9_vVsf/lib/python3.10/site-packages/kombu/connection.py", line 880, in _connection_factory
self._connection = self._establish_connection()
File "/Users/ponponon/.local/share/virtualenvs/test_nameko_for_rabbitmq-Kw9_vVsf/lib/python3.10/site-packages/kombu/connection.py", line 815, in _establish_connection
conn = self.transport.establish_connection()
File "/Users/ponponon/.local/share/virtualenvs/test_nameko_for_rabbitmq-Kw9_vVsf/lib/python3.10/site-packages/kombu/transport/pyamqp.py", line 199, in establish_connection
assert False
AssertionError