Why I Need Cancel Tasks In This Queue Example?
Well I am looking into python documentation for study for my work. I am new to python and also programming, I also do not understand concepts of programming like async operations
Solution 1:
Why in this example i need cancel the tasks?
Because they will otherwise remain hanging indefinitely, waiting for a new item in the queue that will never arrive. In that particular example you are exiting the event loop anyway, so there's no harm from them "hanging", but if you did that as part of a utility function, you would create a coroutine leak.
In other words, canceling the workers tells them to exit because their services are no longer necessary, and is needed to ensure that resources associated with them get freed.
Post a Comment for "Why I Need Cancel Tasks In This Queue Example?"