I think you're confusing JS async API with Python's. In Python, when you call a coroutine function it returns a coroutine (similar to an armed generator) but doesn't schedule it in the event loop. (i.e. doesn't run/consume it)
You have two options:
1) You can await it via await
or the older yield from
.
2) You can asyncio.create_task(coroutine_function())
. This is the equivalent of calling a promise in JS without giving it a handler or awaiting it.
The warning you're seeing is telling you that the coroutine didn't run. it was only created, but not consumed.
As to your code, there are two errors. First urllib is a blocking library, you can't create a task from it, neither can it be ran asynchronously, take a look at aiohttp.ClientSession
instead.
Second, the warning you're seeing is probably caused by you calling AsyncSend
synchronously (without awaiting it). Again, in JS this would probably be fine, as everything in JS is async. In Python, you should use one of the two main methods I mentioned above.
If you insist on using a blocking library, you can run it on a different thread so that you don't block the event loop. As Cloudomation mentioned, to do this. you should use asyncio.run_in_executor(None, lambda: your_urllib_function())
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…