Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for RPC.create() has examples that are incorrect. #638

Open
fake-name opened this issue Jul 13, 2024 · 1 comment
Open

Documentation for RPC.create() has examples that are incorrect. #638

fake-name opened this issue Jul 13, 2024 · 1 comment

Comments

@fake-name
Copy link

From the documentation of RPC.create():

rpc = await RPC.create(channel, host_exceptions=True)

However, trying that:

Traceback (most recent call last):
  File "/media/Scripts/book_cat/rabbit/rpc_llama.py", line 341, in <module>
    run()
  File "/media/Scripts/book_cat/rabbit/rpc_llama.py", line 337, in run
    asyncio.run(instance.run_rpc())
  File "/home/durr/miniconda3/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/home/durr/miniconda3/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/durr/miniconda3/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/media/Scripts/book_cat/rabbit/rpc_llama.py", line 324, in run_rpc
    rpc = await RPC.create(channel, host_exceptions=True)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/durr/miniconda3/lib/python3.12/site-packages/aio_pika/patterns/rpc.py", line 217, in create
    await rpc.initialize(**kwargs)
  File "/home/durr/miniconda3/lib/python3.12/site-packages/aio_pika/patterns/rpc.py", line 174, in initialize
    self.result_queue = await self.channel.declare_queue(
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: RobustChannel.declare_queue() got an unexpected keyword argument 'host_exceptions'

So....., host_exceptions is only valid when passed to RPC.__init__(), which create() does not use.

I dunno who wrote the examples in the docs, but they pretty obviously didn't try any of them.

@fake-name
Copy link
Author

For the moment, I believe you can manually do rpc.host_exceptions = True to work around the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant