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

Worker updates #2938

Merged
merged 21 commits into from
Jul 23, 2023
Merged

Worker updates #2938

merged 21 commits into from
Jul 23, 2023

Conversation

davep
Copy link
Contributor

@davep davep commented Jul 13, 2023

Seeks to implement #2928. In doing so the PR:

  • Adds a thread keyword argument to work.
  • Adds code that checks if the decorated method is async and throws an error if thread=True.
  • Updates DirectoryTree to mark the thread worker as a thread.
  • Updates the thread worker example code to mark the thread worker as a thread.
  • Updates the worker guide to highlight the above checks.
  • Adds the ability to run coroutine-based work as a thread worker.
  • Adds the ability to run awaitable work as a thread worker.
  • Updates the worker-based unit tests to take the above changes into account.
  • Moves the worker-based unit tests into their own subdirectory for easier focused testing.
  • Adds a CHANGELOG entry to point out this is a breaking change.

Also rolled in a couple of tweaks to the overloads for the work decorator to address #2946.

@davep davep self-assigned this Jul 13, 2023
@davep davep added enhancement New feature or request Task labels Jul 13, 2023
@davep davep linked an issue Jul 13, 2023 that may be closed by this pull request
davep added 9 commits July 13, 2023 14:33
Originally the request had been communicated as the following would be
errors:

- Non-async method, non-thread
- Async method, thread

As of
Textualize#2928 (comment)
it's been decided that the scope of the PR should be expanded to not only
guard against the first case, but also to extend the way the worker API
works to do the right thing in the second case.

This commit backs out the detection of the second case and flagging it as an
error.
This makes it far easier to run this subset of tests all at once.
Simplify a wee bit, and also tidy up some of the docstirngs.
@davep davep changed the title Make it harder to accidentally create a thread worker Worker updates Jul 18, 2023
@davep davep marked this pull request as ready for review July 18, 2023 09:58
@davep davep merged commit f78ffe0 into Textualize:main Jul 23, 2023
@davep davep deleted the unfootgun-worker-thread branch July 23, 2023 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revisit and update the typing for the work decorator Worker interface
2 participants