[Flask] Flask + boto3 + apache (mod_wsgi)
Carlos Santana
csantana at studioapp.com.br
Thu May 11 14:50:09 EDT 2017
Hi everyone.
I am developing a restful api using Flask. The main goal of this API is to
manage some resources on the AWS EC2 environment.
Through a request to this api the server will check if some of our EC2
instances are running and for how long.
The first step taken to perform this task was to write a code using only
python libraries and boto3 api. The code worked like a charm.
After this step I wrote a Flask endpoint to serve this request in the
simplest way I could. Again, the code worked very well.
The problems started to begin when this implementation was hosted on an
apache server using mod_wsgi.
I managed to configure the wsgi integration successfully and when I use the
code to check if some of our instances were running an exception with this
(truncated) traceback occurs:
mod_wsgi (pid=4095): Exception occurred processing WSGI script
'/var/www/siase/middleend/rest/cmd_server_wsgi.py'.
Traceback (most recent call last):
File "/var/www/anaconda3/lib/python3.5/site-packages/flask/app.py", line
2000, in __call__
return self.wsgi_app(environ, start_response)
File "/var/www/anaconda3/lib/python3.5/site-packages/flask/app.py", line
1991, in wsgi_app
response = self.make_response(self.handle_exception(e))
File
"/var/www/anaconda3/lib/python3.5/site-packages/flask_cors/extension.py",
line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/var/www/anaconda3/lib/python3.5/site-packages/flask/app.py", line
1567, in handle_exception
(several lines)
File "/var/www/anaconda3/lib/python3.5/site-packages/
botocore/vendored/requests/packages/urllib3/connectionpool.py", line 341,
in _make_request
self._validate_conn(conn)
File "/var/www/anaconda3/lib/python3.5/site-packages/
botocore/vendored/requests/packages/urllib3/connectionpool.py", line 761,
in _validate_conn
conn.connect()
File "/var/www/anaconda3/lib/python3.5/site-packages/
botocore/vendored/requests/packages/urllib3/connection.py", line 206, in
connect
resolved_cert_reqs = resolve_cert_reqs(self.cert_reqs)
File "/var/www/anaconda3/lib/python3.5/site-packages/
botocore/vendored/requests/packages/urllib3/util/ssl_.py", line 157, in
resolve_cert_reqs
res = getattr(ssl, candidate, None)
NameError: name 'ssl' is not defined
This traceback only occurs when my code invokes some boto3 communication
with EC2 service. In other cases, my endpoint works as expected.
Here follows some details of the environment that I currently using:
Apache/2.4.7 (Ubuntu)
OpenSSL 1.0.1f
mod_wsgi 4.5.5
Python 3.5.2 (Anaconda3 - 4.2.0)
Flask 0.11.1
Boto3 1.4.4
To not overextend myself, please ask me what other information do you need
regards my scenario.
Thanks in advance
PS: does this list accept attachments?
--
Carlos Henrique Sant'Ana da Silva
Analista de TI - studioApp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20170511/060fa1aa/attachment.html>
More information about the Flask
mailing list