robinhood / faust

Python Stream Processing
Other
6.7k stars 538 forks source link

Python 3.10 support (loop parameter removed from Queue) #748

Closed gaspect closed 2 years ago

gaspect commented 2 years ago

Checklist

Steps to reproduce

I use this lazy code in a faustapp.py file.

import faust

app = faust.App('Receiver', broker='kafka://localhost:9092')

class Product(faust.Record):
    name:str
    amount:int

@app.agent(value_type=Product)
async def products(prds:faust.Stream[Product]):
    async for p in prds:
        print(p.name, p.amount)

if __name__=='__main__':
    app.main()

Then i ran faust -A faustapp worker -l info

Expected behavior

The usual command result :)

Actual behavior

The command throws the following error:

[2022-01-05 12:32:44,096] [8233] [INFO] [^Worker]: Starting... 
[2022-01-05 12:32:44,102] [8233] [ERROR] [^Worker]: Error: TypeError('As of 3.10, the *loop* parameter was removed from Queue() since it is no longer necessary') 

Full traceback

Traceback (most recent call last):
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/mode/worker.py", line 273, in execute_from_commandline
    self.loop.run_until_complete(self._starting_fut)
  File "/usr/lib64/python3.10/asyncio/base_events.py", line 641, in run_until_complete
    return future.result()
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/mode/services.py", line 736, in start
    await self._default_start()
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/mode/services.py", line 743, in _default_start
    await self._actually_start()
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/mode/services.py", line 767, in _actually_start
    await child.maybe_start()
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/mode/services.py", line 795, in maybe_start
    await self.start()
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/mode/services.py", line 736, in start
    await self._default_start()
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/mode/services.py", line 743, in _default_start
    await self._actually_start()
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/mode/services.py", line 749, in _actually_start
    for dep in self.on_init_dependencies():
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/faust/app/base.py", line 567, in on_init_dependencies
    return self.boot_strategy.server()
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/faust/app/base.py", line 277, in server
    self.kafka_consumer(),
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/faust/app/base.py", line 328, in kafka_consumer
    self.app.consumer,
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/faust/app/base.py", line 1818, in consumer
    self._consumer = self._new_consumer()
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/faust/app/base.py", line 1674, in _new_consumer
    return self.transport.create_consumer(
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/faust/transport/base.py", line 68, in create_consumer
    return self.Consumer(self, callback=callback,
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/faust/transport/consumer.py", line 1231, in __init__
    self._method_queue = MethodQueue(loop=self.loop, beacon=self.beacon)
  File "/home/jesus/Proyectos/.venvs/micro/lib64/python3.10/site-packages/mode/threads.py", line 331, in __init__
    self._queue = asyncio.Queue(loop=self.loop)
  File "/usr/lib64/python3.10/asyncio/queues.py", line 33, in __init__
    super().__init__(loop=loop)
  File "/usr/lib64/python3.10/asyncio/mixins.py", line 17, in __init__
    raise TypeError(
TypeError: As of 3.10, the *loop* parameter was removed from Queue() since it is no longer necessary

Versions

TranTienVan commented 2 years ago

Python 3.10 is not compatible with Faust. I got the same error and switched to Python 3.9.11 and it worked.

michaelurban commented 2 years ago

Python 3.10 was released in October of 2021.. Is Faust still maintained?

g-rd commented 2 years ago

I don't think it is, there is a fork that is maintained, try switching to that.

On Thu, Apr 21, 2022, 19:29 Michael Urban @.***> wrote:

Python 3.10 was released in October of 2021.. Is Faust still maintained?

— Reply to this email directly, view it on GitHub https://github.com/robinhood/faust/issues/748#issuecomment-1105444475, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCAZNXTUIIHXJL4EBPQ2ZTVGF64VANCNFSM5LKQAIHA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

gaspect commented 2 years ago

It's a bit late, since I wrote the question. I solved the problem using the AIOKafka low-level library and on the way I changed the message broker. But for those who are still interested in using Faust a fork of the project is still maintained in this repository.