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

Bug: RPC not working with anyio <4.0 #1539

Closed
ardagk opened this issue Jun 20, 2024 · 1 comment · Fixed by #1541
Closed

Bug: RPC not working with anyio <4.0 #1539

ardagk opened this issue Jun 20, 2024 · 1 comment · Fixed by #1541
Labels
bug Something isn't working

Comments

@ardagk
Copy link

ardagk commented Jun 20, 2024

Describe the bug
I'm currently using faststream with anyio==3.7.1 and python3.10.10 which both seems to meet the requirements.

When publishing with rpc=True, I encounter this error:

File "/***/python3.10/site-packages/faststream/rabbit/publisher/producer.py", line 209, in __aenter__
    ) = anyio.create_memory_object_stream[AbstractIncomingMessage](
TypeError: 'function' object is not subscriptable

From my understanding of their docs bracket notation wasn't introduced until v4.0. (above this version works as expected)

How to reproduce

send.py

import asyncio
from faststream.rabbit import RabbitBroker, RabbitExchange, RabbitQueue

exchange = RabbitExchange('ai')
queue = RabbitQueue('test')
broker = RabbitBroker()

async def t():
    await broker.connect()
    await send(1, broker)


async def send(num, broker):
    out = await broker.publish(num, queue=queue, exchange=exchange, rpc=True)
    print(out)

asyncio.run(t())

app.py

import asyncio

from faststream import FastStream, Logger
from faststream.rabbit import RabbitBroker, RabbitExchange, RabbitQueue

broker = RabbitBroker()
app = FastStream(broker)

exchange = RabbitExchange('ai')
queue = RabbitQueue('test')

@broker.subscriber(queue=queue, exchange=exchange)
async def handler(msg, logger: Logger):
    logger.info(msg)
    return msg

Environment
Running FastStream 0.5.12 with CPython 3.10.10 on Darwin

@ardagk ardagk added the bug Something isn't working label Jun 20, 2024
@Lancetnik
Copy link
Member

Thank your for the Issue! I'll fix it soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants