-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework ui_dispatch tests to avoid need for Qt (#1792)
Since #1788, we have only one test module that makes use of the Qt event loop. That test module contains tests for the behaviour of handlers that use `dispatch='ui'` mechanism to redispatch off-thread notifications to the ui thread. This PR reworks that test module, with some significant collateral damage along the way. In detail: - reworks that test module (`test_ui_notifiers`) to avoid the need for the Qt event loop; instead, it tests against a `ui_handler` based on asyncio, which redispatches to the running asyncio event loop - adds a `get_ui_handler` counterpart to `set_ui_handler`, and exposes both functions in `traits.api` - adds type hints for `get_ui_handler` and `set_ui_handler` - removes two public module globals from `trait_notifiers`: `ui_handler` has been made private, while `ui_thread` is removed altogether - fixes a bug where ui dispatch didn't do the right thing (PR #1740 was incomplete; this bug should have been caught at review time on that PR) - makes another couple of drive-by cleanups, removing a very old check for `threading.local()` being a dict (which it hasn't been in living memory), and tidying up some uses of thread identity.
- Loading branch information
1 parent
9cfaf74
commit 2bc548f
Showing
6 changed files
with
169 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from typing import Callable | ||
|
||
_UI_Handler = Callable[..., None] | None | ||
|
||
|
||
def get_ui_handler() -> _UI_Handler: ... | ||
|
||
def set_ui_handler(handler: _UI_Handler) -> None: ... |