Feature Request: add 'close' method to IGUI interface
- Dominant language
- Python
- Stars
- 115
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
Some downstream `IGUI` implementations allocate system resources, or modify global state, at instance creation time. (For example, one `GUI` subclass that we have in a downstream project changes the `asyncio` global event loop.) As a result, we've added `close` methods to those implementations to allow those resources to be released, and global state changes to be reverted. It's particularly important to have this functionality available in test suites, where many `IGUI` instances are being created and destroyed within a single process.
To allow polymorphic cleanup, it would be useful to add a `close` method to the `IGUI` interface itself, and the `GUI` base class. The base class implementation would do nothing.
This isn't without backwards compatibility risks: as always, an interface is a point of rigidity in a system, and in particular adding a `close` method would invalidate any existing implementations of `IGUI` that don't already inherit from the`GUI` base class. However, I'm not aware of any such implementations in practice, and I think the risk here is manageable.
On details: we'd need to decide whether it's also useful to have an `is_closed` property. The minimal useful interface would be just the `close` method, together with a guarantee that `close` is idempotent, so that it's always safe to call `close` even if you're not sure whether the `IGUI` object is already closed.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.