bpo-36373: Fix deprecation warnings#15889
Conversation
There was a problem hiding this comment.
LGTM. As I understand previously we were always passing self._loop which would always be initialized with a loop object and would mean we are passing the loop value to the other callers though the initial caller had loop=None only. This looks more correct and simple to me given asyncio.Queue() is a valid call. Thanks Andrew.
Sorry, something went wrong.
|
I thought we were going to be more subtle about this. We have two scenarios:
The (1) approach is how people were used to writing asyncio programs before The (2) approach is how we want people to write asyncio programs. There's a subtle difference between things like If we remove the @asvetlov thoughts? |
Sorry, something went wrong.
1st1
left a comment
There was a problem hiding this comment.
Please don't merge this until we discuss it.
Sorry, something went wrong.
|
When you're done making the requested changes, leave the comment: |
Sorry, something went wrong.
|
On Python 3.6 where Also, please read comment above. In aiohttp we forbade the creation of |
Sorry, something went wrong.
|
Alright. |
Sorry, something went wrong.
|
Thanks @asvetlov for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
Sorry, something went wrong.
|
Thanks @asvetlov for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
Sorry, something went wrong.
|
Sorry @asvetlov, I had trouble checking out the |
Sorry, something went wrong.
https://bugs.python.org/issue36373 (cherry picked from commit 7264e92) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
https://bugs.python.org/issue36373 (cherry picked from commit 7264e92) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
|
Is there a drop in replacement for code that was previously using the |
Sorry, something went wrong.
|
I had the same issue and found this workaround. # Create an event loop that will run in a background thread.
loop = asyncio.new_event_loop()
+ # Due to zealous removal of the loop parameter in the Queue constructor,
+ # we need a factory coroutine to run in the freshly created event loop.
+ async def queue_factory() -> asyncio.Queue[str]:
+ return asyncio.Queue()
+
# Create a queue of user inputs. There's no need to limit its size.
- inputs: asyncio.Queue[str] = asyncio.Queue(loop=loop)
+ inputs: asyncio.Queue[str] = loop.run_until_complete(queue_factory())
# Create a stop condition when receiving SIGINT or SIGTERM.
stop: asyncio.Future[None] = loop.create_future()Forcing the introduction of factory functions counts as progress towards Java, I guess... |
Sorry, something went wrong.
|
I ended up here after following deprecation warning -> git blame -> ticket -> comments. I have a case of an asynchronous loop running on another thread already, and a synchronous program that creates tasks to run on it. Basically like background workers. Trying to go a generic way here. Maybe they would be some existing helpers but I did not find it yet. |
Sorry, something went wrong.
https://bugs.python.org/issue36373
Automerge-Triggered-By: @asvetlov