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

Allow use without importing glib backend. #242

Closed
dlech opened this issue Sep 7, 2023 · 1 comment · Fixed by #243
Closed

Allow use without importing glib backend. #242

dlech opened this issue Sep 7, 2023 · 1 comment · Fixed by #243
Labels
enhancement New feature or request

Comments

@dlech
Copy link
Collaborator

dlech commented Sep 7, 2023

Is your feature request related to a problem? Please describe.
This came up in hbldh/bleak#1412

In addition to avoiding a crash like in this case, it would be nice to improve startup time and reduce memory usage on constrained systems where gi is installed.

Describe the solution you'd like
The top-level __init__.py should not import aio or glib. It should be up to the library user to import the backend they want to use.

Additional context
I also wouldn't be opposed to dropping the glib backend completely and making this library asyncio-only.

@dlech dlech added the enhancement New feature or request label Sep 7, 2023
@bdraco
Copy link
Member

bdraco commented Sep 7, 2023

Thats a good idea. I'm not sure if we should drop glib completely though, but definitely run time load

dlech added a commit that referenced this issue Sep 7, 2023
Since the top-level `__init__.py` is always imported when any subpackage
is imported, this caused both backends (glib and aio) to always be
imported. This is not desirable, since it means that the glib backend
will always be imported, even if the user only wants to use the aio.
This wastes resources and in some cases can even cause a crash.

Fixes: #242
dlech added a commit that referenced this issue Sep 7, 2023
Since the top-level `__init__.py` is always imported when any subpackage
is imported, this caused both backends (glib and aio) to always be
imported. This is not desirable, since it means that the glib backend
will always be imported, even if the user only wants to use the aio.
This wastes resources and in some cases can even cause a crash.

Fixes: #242
dlech added a commit that referenced this issue Sep 7, 2023
BREAKING CHANGE:
Since the top-level `__init__.py` is always imported when any subpackage
is imported, this caused both backends (glib and aio) to always be
imported. This is not desirable, since it means that the glib backend
will always be imported, even if the user only wants to use the aio.
This wastes resources and in some cases can even cause a crash.

Fixes: #242
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants