Repository: eventlet/eventlet (Python)

Issue:
ModuleNotFoundError: No module named 'OpenSSL.tsafe'
Using the following Pipenv:

```
[[source]]
name = "pypi"
url = "https://pypi.org/simple"

[packages]
pyOpenSSL = "*"
eventlet = "*"

[requires]
python_version = "3"
```

Create a pipenv using that file:

```
$ pipenv install
Creating a virtualenv for this project…
Pipfile: /tmp/Pipfile
Using /usr/local/bin/python3.8 (3.8.3) to create virtualenv…
...
Successfully created virtual environment! 
...

```

Now import eventlet.green.OpenSSL.SSL:

```
$ pipenv run python
Python 3.8.3 (default, Jun 29 2020, 18:02:49) 
[GCC 8.3.1 20190311 (Red Hat 8.3.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from eventlet.green.OpenSSL import SSL
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/myuser/.local/share/virtualenvs/tmp-XVr6zr33/lib/python3.8/site-packages/eventlet/green/OpenSSL/__init__.py", line 3, in <module>
    from . import tsafe
  File "/home/myuser/.local/share/virtualenvs/tmp-XVr6zr33/lib/python3.8/site-packages/eventlet/green/OpenSSL/tsafe.py", line 1, in <module>
    from OpenSSL.tsafe import *
ModuleNotFoundError: No module named 'OpenSSL.tsafe'
>>> 

```

I suspect this has to do with the following PyOpenSSL commit which is now released via 20.0.0:
https://github.com/pyca/pyopenssl/commit/2dca7a75eef7c931abbbb6b9a87b1659db5ae6c8


Discussion:
Thanks, Brian. As workaround, you may just remove pyOpenSSL from virtualenv if possible, or temporary pin it to `<20`
> Thanks, Brian. As workaround, you may just remove pyOpenSSL from virtualenv if possible, or temporary pin it to `<20`

Thanks for the quick reply. Yes, I can pin it to the previous release:

`pyOpenSSL = "==19.1.0"
`

That will currently work around the issue for me. I cannot remove it, however. If I could I'd never have hit this issue because I wouldn't have tried the import.
@bneradt Please, try again with latest code.

`pip install https://github.com/eventlet/eventlet/archive/master.zip`
> @bneradt Please, try again with latest code.
> 
> `pip install https://github.com/eventlet/eventlet/archive/master.zip`

Looks good.

### Verification Steps

I repeated the steps described in the description. I created a new Pipenv using the Pipfile described there. Pipfile.lock shows I'm testing with the following latest eventlet and PyOpenSSL packages:

* [v0.30.0](https://github.com/eventlet/eventlet/releases/tag/v0.30.0) of eventlet
* [20.0.0](https://github.com/pyca/pyopenssl/releases/tag/20.0.0) of pyopenssl

With these packages installed, I can now import eventlet's SSL without issue:

```
$ pipenv run python
Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from eventlet.green.OpenSSL import SSL
>>> 
```

Thank you for a quick turn around of a solution!



Patch:
diff --git a/.travis.yml b/.travis.yml
index 163faa78c2..2c9bc22daa 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -32,6 +32,7 @@ jobs:
     - {python: pypy, env: TOXENV=pypy-selects}
 
     - {python: 3.6, env: TOXENV=ipv6}
+    - {python: 3.8, env: TOXENV=py38-openssl}
   allow_failures:
     - python: 3.7-dev
     - python: pypy
diff --git a/eventlet/green/OpenSSL/__init__.py b/eventlet/green/OpenSSL/__init__.py
index d861476454..1b25009710 100644
--- a/eventlet/green/OpenSSL/__init__.py
+++ b/eventlet/green/OpenSSL/__init__.py
@@ -1,4 +1,9 @@
 from . import crypto
 from . import SSL
-from . import tsafe
+try:
+    # pyopenssl tsafe module was deprecated and removed in v20.0.0
+    # https://github.com/pyca/pyopenssl/pull/913
+    from . import tsafe
+except ImportError:
+    pass
 from .version import __version__
diff --git a/tox.ini b/tox.ini
index 5369820b0f..ce2fd398f9 100644
--- a/tox.ini
+++ b/tox.ini
@@ -16,7 +16,7 @@ statistics = 1
 [tox]
 minversion=2.5
 envlist =
-    ipv6, pep8, py{27,35,36,37,38,py}-{selects,poll,epolls}
+    ipv6, pep8, py{27,35,36,37,38,py}-{selects,poll,epolls}, py38-openssl
 
 [testenv:ipv6]
 basepython = python
@@ -65,6 +65,7 @@ deps =
     pypy: psycopg2cffi-compat==1.1
     py{27,35,36,37}: psycopg2-binary==2.7.4
     py38: psycopg2-binary==2.8.4
+    py38-openssl: pyopenssl==20.0.0
     py27-{selects,poll,epolls}: pyopenssl==17.3.0
     setuptools==38.5.1
     {selects,poll,epolls}: pyzmq==17.0.0


Test patch:
diff --git a/tests/openssl_test.py b/tests/openssl_test.py
index a127408b85..1108adaf68 100644
--- a/tests/openssl_test.py
+++ b/tests/openssl_test.py
@@ -12,5 +12,4 @@ def test_import():
 
     import eventlet.green.OpenSSL.SSL
     import eventlet.green.OpenSSL.crypto
-    import eventlet.green.OpenSSL.tsafe
     import eventlet.green.OpenSSL.version