Traits Futures 0.2.0
This is a feature release of Traits Futures. The main features of this
release are:
- Improved support for user-defined background task types.
- Easier creation of background calculations that can be (cooperatively)
cancelled mid-calculation. - Significant internal refactoring and cleanup, aimed at eventual support
for alternative front ends (GUI event loops other than the Qt event
loop) and back ends (e.g., multiprocessing). - Improved and expanded documentation.
There are no immediately API-breaking changes in this release: existing working
code using Traits Futures 0.1.1 should continue to work with no changes
required. However, some parts of the existing API have been deprecated, and
will be removed in a future release. See the Changes section below for more
details.
Detailed changes follow. Note that the list below is not exhaustive: many
more minor PRs have been omitted.
Features
- Users can now easily create their own background task types to supplement
the provided task types (background calls, background iterations and
background progress). A combination of a newITaskSpecification
interface and a convenienceBaseFuturebase class support this.
(#198) - The
submit_iterationfunction now supports generator functions that
return a result. This provides an easy way to submit background computations
that can be cancelled mid-calculation. (#167) - The
TraitsExecutorclass now accepts amax_workersargument,
which specifies the maximum number of workers for a worker pool created
by the executor. (#125) - There are new task submission functions
submit_call,
submit_iterationandsubmit_progress. These functions replace
the eponymous existingTraitsExecutormethods, which are now
deprecated. (#166) - There's a new
IFutureinterface class in the
traits_futures.apimodule, to aid in typing and Trait declarations.
(#169) - A new
IParallelContextinterface supports eventual addition
of alternative back ends. The newMultithreadingContextclass
implements this interface and provides the default threading back-end.
(#149)
Changes
- The
statetrait onCallFuture,IterationFutureandProgressFutureis
now read-only. It used to be writable. - The default number of workers in an owned worker pool (that is, a worker pool
created by aTraitsExecutor) has changed. Previously it was
hard-coded as4. Now it defaults to whatever Python's
concurrent.futuresexecutors give, but can be controlled by passing
themax_workersargument. (#125) - The
submit_call,submit_iterationandsubmit_progress
methods on theTraitsExecutorhave been deprecated. Use the
submit_call,submit_iterationandsubmit_progress
convenience functions instead. (#159) - The
thread_poolargument toTraitsExecutorhas been renamed
toworker_pool. The original name is still available for backwards
compatibility, but its use is deprecated. (#144, #148) - Python 2.7 is no longer supported. Traits Futures requires Python >= 3.5,
and has been tested with Python 3.5 through Python 3.9. (#123, #130, #131,
#132, #133, #138, #145)
Fixes
- Don't create a new MessageRouter at executor shutdown time. (#187)
Tests
- Fix some intermittent test failures due to test interactions. (#176)
- The 'null' backend that's used for testing in the absence of a Qt backend
now uses aasyncio-based event loop instead of a custom event loop.
(#107, #179) - Rewrite the Qt
GuiTestAssistantto react rather than polling. This
significantly speeds up the test run. (#153) - Ensure that all tests properly stop the executors they create. (#108, #146)
- Refactor the test structure in preparation for multiprocessing
support. (#135, #141) - Test the
GuiTestAssistantclass. (#109)
Developer tooling
- Add a new
python -m ci shellclick cmd. (#204) - Update edm version in CI. (#205)
- Add checks for missing or malformed copyright headers in Python files (and
fix existing copyright headers). (#193) - Add import order checks (and fix existing import order bugs). (#161)
- Add separate "build" and "ci" modes for setting up the development
environment. (#104) - Don't pin dependent packages in the build environment. (#99)
Documentation
- Update docs to use the Enthought Sphinx Theme. (#128)
- Autogenerated API documentation is now included in the documentation
build. (#177, #181) - Restructure the documentation to avoid nesting 'User Guide'
under 'User Documentation'. (#191) - Document creation of new background task types. (#198)
- Document use of
submit_iterationfor interruptible tasks. (#188)