Created
March 25, 2018 08:54
-
-
Save pfreixes/86df929da6c0d564f4cd23da6611d2d2 to your computer and use it in GitHub Desktop.
The id of different Asyncio tasks are the same due to the CPython memory implementation for objects smaller than X bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import sys | |
async def foo(): | |
pass | |
async def test(): | |
t = asyncio.tasks.create_task(foo()) | |
print(sys.getsizeof(t)) | |
print(id(t)) | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(test()) | |
loop.run_until_complete(test()) | |
loop.run_until_complete(test()) |
Author
pfreixes
commented
Mar 25, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment