Hi! So, I have a traditional Flask app using flask-sqlalchemy and sqlalchemy ORM, served with uwsgi. Uwsgi is set with processes=4 and threads=4. Yesterday I added grequests to improve a single area of the app a bit (I had to do a couple hundred external API calls to build a single data structure). No problem- except that I started getting errors like
/usr/local/lib/python2.7/dist-packages/flask_sqlalchemy/__init__.py", line 423, in first_or_404 rv = self.first() File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2634, in first ret = list(self[0:1]) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2457, in __getitem__ return list(res) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2736, in __iter__ return self._execute_and_instances(context) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2751, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 914, in execute return meth(self, multiparams, params) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement compiled_sql, distilled_params File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1078, in _execute_context None, None) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception exc_info File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 200, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1073, in _execute_context context = constructor(dialect, self, conn, *args) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 558, in _init_compiled self.cursor = self.create_cursor() File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 748, in create_cursor return self._dbapi_connection.cursor() File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 852, in cursor return self.connection.cursor(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/mysql/connector/connection.py", line 807, in cursor raise errors.OperationalError("MySQL Connection not available.") OperationalError: (mysql.connector.errors.OperationalError) MySQL Connection not available. >From playing around with it, importing grequests was the line of code that made the error appear/dis-appear. Further experimenting shows that `import gevent.monkey; gevent.monkey.patch_all()` anywhere in the code breaks the app as well. This doesn't happen on every request, and I am not actually using greenlets or the gevent loop anywhere in the endpoints I am accessing. For now this is easy enough for me to just rip out grequests, but I was wondering if anyone had any ideas as to why this is happening? -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.