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

.execute_write(... block=True) should be the default behaviour #1579

Closed
simonw opened this issue Dec 23, 2021 · 7 comments
Closed

.execute_write(... block=True) should be the default behaviour #1579

simonw opened this issue Dec 23, 2021 · 7 comments

Comments

@simonw
Copy link
Owner

simonw commented Dec 23, 2021

Every single piece of code I've written against the write APIs has used the block=True option to wait for the result.

Without that, it instead fires the write into the queue but then continues even before it has finished executing.

block=True should clearly be the default behaviour here!

@simonw simonw added this to the Datasette 1.0 milestone Dec 23, 2021
@simonw
Copy link
Owner Author

simonw commented Dec 23, 2021

This is technically a breaking change, but a GitHub code search at https://cs.github.com/?scopeName=All+repos&scope=&q=execute_write%20datasette%20-owner%3Asimonw shows only one repo not-owned-by-me using this, and they're using block=True: https://github.com/mfa/datasette-webhook-write/blob/e82440f372a2f2e3ed27d1bd34c9fa3a53b49b94/datasette_webhook_write/__init__.py#L88-L89

@simonw
Copy link
Owner Author

simonw commented Dec 23, 2021

The easiest way to change this would be to default to block=True such that you need to pass block=False to the APIs to have them do fire-and-forget.

An alternative would be to add new, separately named methods which do the fire-and-forget thing.

If I hadn't recently added execute_write_script and execute_write_many in #1570 I'd be more into this idea, but I don't want to end up with eight methods - execute_write, execute_write_queue, execute_write_many, execute_write_many_queue, execute_write_script, execute_write_scrript_queue, execute_write_fn, execute_write_fn_queue.

@simonw
Copy link
Owner Author

simonw commented Dec 23, 2021

I'm going to go with execute_write(..., block=False) as the mechanism for fire-and-forget write queries.

@simonw simonw closed this as completed in 00a2895 Dec 23, 2021
@simonw
Copy link
Owner Author

simonw commented Dec 23, 2021

Re-opening this because I missed updating some of the docs, and I also need to update Datasette's own code to not use block=True in a bunch of places.

@simonw
Copy link
Owner Author

simonw commented Dec 23, 2021

@simonw
Copy link
Owner Author

simonw commented Dec 23, 2021

All of those removed block=True lines in 8c401ee really help confirm to me that this was a good decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant