[Python-Dev] Investigating time for import requests
(original) (raw)
Eric V. Smith eric at trueblade.com
Sun Oct 8 18:46:12 EDT 2017
- Previous message (by thread): [Python-Dev] Investigating time for `import requests`
- Next message (by thread): [Python-Dev] Investigating time for `import requests`
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The easiest workaround at the moment is still pretty clumsy:
def importSLLError(): from requests.exceptions import SLLError return SLLError ...
except importSLLError(): But what happens if that gives you an ImportError?
You can't catch a requests exception unless requests has already been imported, you could do something like:
except Exception as ex:
if 'requests' in sys.modules:
import requests # this is basically free at this point
if isinstance(ex, requests.exceptions):
...
Eric.
- Previous message (by thread): [Python-Dev] Investigating time for `import requests`
- Next message (by thread): [Python-Dev] Investigating time for `import requests`
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]