Skip to content
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

submit_iteration should not send a message on a plain yield #229

Open
mdickinson opened this issue Nov 3, 2020 · 3 comments
Open

submit_iteration should not send a message on a plain yield #229

mdickinson opened this issue Nov 3, 2020 · 3 comments
Labels
type: enhancement New feature or request

Comments

@mdickinson
Copy link
Member

mdickinson commented Nov 3, 2020

Currently a yield expression in a generator submitted to submit_iteration serves two purposes:

  • it sends a message (which could be a status message, a partial result, progress information, or whatever the user wants) to the corresponding future
  • it provides a point at which cancellation is checked

However, there's more overhead in the message sending than in the cancellation check. It may make sense not to send any message on a plain yield (or on a yield None, which is indistinguishable at Python level), and only send messages for a non-None expression in a statement of the form yield expression.

This would be a backwards compatibility break. The recommendation for users who want to react to a yield even when that yield contains no additional information would be to use yield True.

@mdickinson mdickinson added this to the Release 0.3.0 milestone Nov 3, 2020
@mdickinson mdickinson added type: enhancement New feature or request good first issue Good for newcomers labels Nov 9, 2020
@mdickinson
Copy link
Member Author

This would be a good first issue for anyone who wants to get their feet wet with Traits Futures.

@mdickinson
Copy link
Member Author

See the last comment on #236:

Closing. This doesn't seem like the right way to go, partly because of the backwards compatibility break, partly because wanting to receive all values (None or not) from a background iteration seems like a genuine use-case that we shouldn't break, and partly because using submit_iteration when what you want is an interruptible background call already seems like a strained non-obvious API, and doesn't allow users to easily express the intent.

Instead, I think we want a new submission function submit_interruptible that allows submission of a generator factory (almost always a generator function in practice) representing an interruptible computation, plus whatever other machinery is needed to support that.

@mdickinson
Copy link
Member Author

Not in this release.

@mdickinson mdickinson removed this from the Release 0.3.0 milestone Jul 6, 2021
@mdickinson mdickinson removed the good first issue Good for newcomers label Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant