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

Implement deferred SSL import #275

Open
bskinn opened this issue Dec 7, 2022 · 2 comments
Open

Implement deferred SSL import #275

bskinn opened this issue Dec 7, 2022 · 2 comments
Labels
Milestone

Comments

@bskinn
Copy link
Owner

bskinn commented Dec 7, 2022

This will be necessary in order for bskinn/soi-app#10 to work, at all. PyScript doesn't ship with a working ssl package, and sphobjinv imports ssl at import time.

sphobjinv doesn't use SSL except for Inventory(url=...) instantiation. Any ImportError that occurs during an attempt to import ssl will need to be deferred until such time that Inventory(url=...) is attempted.

This means that the creation of Inventory._sslcontext will also have to be deferred, since ssl is used to create that context. Thus, #113 will be needed for functional reasons.

@bskinn bskinn added this to the v2.4 milestone Dec 7, 2022
@bskinn
Copy link
Owner Author

bskinn commented Dec 7, 2022

A simple descriptor might be enough. Inside Inventory:

class Inventory(...):

    ...

    _sslcontext_obj = None

    @property
    def _sslcontext(self):
        # This is clunky and not best practice. Could also work with top-level import
        # and and just defer the exception to this use of ssl....have to decide.
        import ssl
        if not self._sslcontext_obj:
            self._sslcontext_obj = ssl. ...

        return self._sslcontext_obj

@bskinn
Copy link
Owner Author

bskinn commented Apr 2, 2024

Note to self: There is request capability in Pyodide and PyScript, it just is accessed differently. So, we would want to to some import-time testing to see what's available, and then use the first option that works out of a priority-sequenced cascade of options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant