Earlier quoted context omitted.
Can you give an example of what you consider a good solution in a different language? That will help us see exactly what you're looking for and how/whether it might be achieved in Python.
Erlang and Elixir. :)
Think Python, 3rd Edition
61–70 of 126 posts
Re: Think Python, 3rd Edition
#62Earlier quoted context omitted.
Erlang and Elixir. :)
Well RabbitMQ is built in Erlang so there you go :)
Re: Think Python, 3rd Edition
#63Earlier quoted context omitted.
Well RabbitMQ is built in Erlang so there you go :)
But RabbitMQ is just a messaging bus, isn't it? That doesn't handle the processes (operating system processes or virtual processes) actually processing the messages and those processes handling fault-tolerance for the things they're connected to.
Re: Think Python, 3rd Edition
#64Apologies for changing the subject, but aside from real world experience (which I have and am getting at work), is there a resource of similar quality for more intermediate/advanced Python programmers? I always feel like there's a big chunk of the language or stdlib I do not know.
Re: Think Python, 3rd Edition
#65Earlier quoted context omitted.
Use asyncio. Bind to a socket, set blocking False, then asyncio.run(on_new_connection(sock)). Inside that coroutine get the loop and await loop.sock_accept(sock) And then asyncio.create_task(on_connection_data(connection)). The only gotcha is you need to keep a reference to that task so it doesn't get garbage collected.
Get garbage collected by what? Doesn’t Python use reference counting?
Consider organizing the code using TaskGroup.
Re: Think Python, 3rd Edition
#66Re: Think Python, 3rd Edition
#67What is a good book for learning Python when you already now some/many other languages?
Re: Think Python, 3rd Edition
#68Apologies for changing the subject, but aside from real world experience (which I have and am getting at work), is there a resource of similar quality for more intermediate/advanced Python programmers? I always feel like there's a big chunk of the language or stdlib I do not know.
Also just reading Norvig’s annual Advent of Code implementations usually provides some insight on how to write elegant and concise Python code.
Re: Think Python, 3rd Edition
#69Apologies for changing the subject, but aside from real world experience (which I have and am getting at work), is there a resource of similar quality for more intermediate/advanced Python programmers? I always feel like there's a big chunk of the language or stdlib I do not know.
https://docs.python.org/3/tutorial/index.html
https://docs.python.org/3/library/index.html
Whenever a new version is released, I read its What's New documentation.
Beyond that, I like to read source code, both for the stdlib and popular third-party packages. This advice generally applies when I'm learning any new language or re-familiarizing myself with one, not just Python.
Re: Think Python, 3rd Edition
#70Earlier quoted context omitted.
But RabbitMQ is just a messaging bus, isn't it? That doesn't handle the processes (operating system processes or virtual processes) actually processing the messages and those processes handling fault-tolerance for the things they're connected to.
That is correct. Honestly I’m not sure this is a good use case for Python but it’s definitely possible. I’ve used the RabbitMQ + gevent + multiprocessing pattern in the past and it works but I find the code extremely hard to reason about. If I were doing it again from scratch I’d probably choose another language with better concurrency primitives.
It definitely isn't, but this is a new role with a rushed timeline in a place dominated by Python.
> and it works but I find the code extremely hard to reason about
This is also a major concern of mine.