-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
channel.close() less useful than thought #53
Comments
Original comment by Kristján Valur Jónsson (Bitbucket: krisvale, GitHub: kristjanvalur): @ctismer |
Original comment by Kristján Valur Jónsson (Bitbucket: krisvale, GitHub: kristjanvalur): Interesting, maybe it is only my interactive web page that doesn't expand it in realtime. Same when trying to add him as a pull request reviewer... |
Original comment by Anonymous: The behavior is exactly as I designed at that time, I remember that I had reasons |
Original comment by Anonymous: @krisvale tagging did work nicely for me - it clearly tells be to be directly addressed. |
Original comment by Kristján Valur Jónsson (Bitbucket: krisvale, GitHub: kristjanvalur): Well, We should probably try to dig out some use cases. channel.close(hard=True) #close the channel and awake any waiting tasklets with an exception. next tasklets get StopIteration, others get ValueError. |
Original comment by Kristján Valur Jónsson (Bitbucket: krisvale, GitHub: kristjanvalur): (We didn't even have unittests for iter(channel) until today, I think) |
Original comment by Anonymous: Ah, I get closer to close()... Maybe the name of the function/flags was unfortunate. I did not want a close action
This is kind of future, and waking up anything was exactly not what I wanted. I think the sequence protocol was added later, and it doesn't fit this case. |
Original comment by Kristján Valur Jónsson (Bitbucket: krisvale, GitHub: kristjanvalur): Right, but the sequence protocol is basically broken because of this, unless you explicitly send StopIteration at the end manually. Which is not really how you should do things. So, do we want to add a function, or a flag to a channel to properly support the iterator protocol? |
Original comment by Anonymous: I think the "closing" flag was just the idea to know that the channel will be closing. Yes, let's improve that. When close is called, then this close call should
Does that make sense at all, or should we throw that away, simply? |
Original comment by Kristján Valur Jónsson (Bitbucket: krisvale, GitHub: kristjanvalur): I have no idea :) In the end I suppose, it all depends on what people want, and what people are already using and comforable with. I propose we postpone this issue past 2.7.6 release. |
Original comment by Anonymous: The iterator thing was the hope to get some benefit from sending or receiving a bulk of data over a channel and to have a way to limit that. Not sure about it. I added this when I used stackless for a larger project, myself. But that was 10 years ago. Good that we have this as a dormant issue, at least. |
Original comment by Anselm Kruis (Bitbucket: akruis, GitHub: akruis): This issue is related to #78. Therefore I tried the following variant of Kristjáns example.
Therefore I propose to document, that
Then I'll change the status of this issue to "on hold" and wait for an implementation. |
Originally reported by: Kristján Valur Jónsson (Bitbucket: krisvale, GitHub: kristjanvalur)
Writing a unittest for sending a sequence through a channel, I tried the obvious, but failed:
This doesn't work, however. The receiver is stuck on a iter.next call at the end.
This is because when the sender calls close, the channel balance is already -1. So it is set into 'closing' state, but that is it.
In order to do this properly, the functions needed to be tweaked like this:
I wonder if this system is how we want to do it? Wouldn't it be nicer if close() were immediate? It would wake up any blocked tasklets right away? We would get rid of the 'closing' attribute, or make it synonomous with 'closed'.
As it is, I don't really se a use case for the sequence protocol if it needs to be shored up in boilerplate anyway.
Is there a use case for the current closing/closed state transfer?
The text was updated successfully, but these errors were encountered: