Message298388
| Author |
Rokas K. (rku) |
| Recipients |
Rokas K. (rku), djarb, gvanrossum, martin.panter, vstinner, yselivanov |
| Date |
2017年07月15日.08:21:46 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1500106907.69.0.0486412919598.issue22239@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I understand rationale for rejection of this issue but i beg to reconsider.
Unlike in traditional coroutines (windows fibers / setjmp|longjmp with stack switching) we can not yield from any point of execution. There must be full async-await chain preserved. This basically divides code into two islands - async and non-async. And there seems to be no way to schedule async call from non-async code and get a response. While suggestion to make custom `async def contains()` call is a valid one we can not always do that. Consider the case when we have to do some networking calls in a function that is invoked by non-async library. Naturally it would be simple non-awaited call from which we can not call a coroutine and get a response. And since it is a library calling into our code we can not easily change it. It might even be completely unsuitable change for library in question.
I see two solutions to this problem (if i am missing something please point it out):
1. Reentrant loops as suggested in this issue.
2. Allow awaited calls from non-coroutines provided execution is invoked from a coroutine somewhere up the call stack.
First one is certainly easier to implement. |
|