title: "cannot allocate memory in static TLS block" in a Python Flask application
body: <p>I've searched online but haven't found anything that fixed my issue. I'm writing a web app in Flask using Python, but after transferring my data to a new computer and recreating the virtual environment, I'm no longer able to use Flask's built-in development web server. I'm getting the traceback below. I can't tell if the issue lies in the SQL or Flask modules, but I've tried reinstalling and compiling them from source to no avail. The application throws the same error even when not in the virtual environment, as well.</p>
  <pre><code>127.0.0.1 - - [07/Aug/2020 14:29:49] &quot;GET / HTTP/1.1&quot; 500 -
  Traceback (most recent call last):
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/sqlalchemy/util/_collections.py&quot;, line 1020, in __call__
      return self.registry[key]
  KeyError: 139700690765568
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/app.py&quot;, line 2463, in __call__
      return self.wsgi_app(environ, start_response)
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/app.py&quot;, line 2449, in wsgi_app
      response = self.handle_exception(e)
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/app.py&quot;, line 1866, in handle_exception
      reraise(exc_type, exc_value, tb)
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/_compat.py&quot;, line 39, in reraise
      raise value
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/app.py&quot;, line 2446, in wsgi_app
      response = self.full_dispatch_request()
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/app.py&quot;, line 1952, in full_dispatch_request
      return self.finalize_request(rv)
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/app.py&quot;, line 1969, in finalize_request
      response = self.process_response(response)
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/app.py&quot;, line 2268, in process_response
      self.session_interface.save_session(self, ctx.session, response)
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask_session/sessions.py&quot;, line 534, in save_session
      saved_session = self.sql_session_model.query.filter_by(
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py&quot;, line 519, in __get__
      return type.query_class(mapper, session=self.sa.session())
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/sqlalchemy/orm/scoping.py&quot;, line 78, in __call__
      return self.registry()
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/sqlalchemy/util/_collections.py&quot;, line 1022, in __call__
      return self.registry.setdefault(key, self.createfunc())
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 3286, in __call__
      return self.class_(**local_kw)
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py&quot;, line 138, in __init__
      bind = options.pop('bind', None) or db.engine
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py&quot;, line 937, in engine
      return self.get_engine()
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py&quot;, line 956, in get_engine
      return connector.get_engine()
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py&quot;, line 561, in get_engine
      self._engine = rv = self._sa.create_engine(sa_url, options)
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py&quot;, line 966, in create_engine
      return sqlalchemy.create_engine(sa_url, **engine_opts)
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/sqlalchemy/engine/__init__.py&quot;, line 500, in create_engine
      return strategy.create(*args, **kwargs)
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/sqlalchemy/engine/strategies.py&quot;, line 87, in create
      dbapi = dialect_cls.dbapi(**dbapi_args)
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/sqlalchemy/dialects/mysql/mysqldb.py&quot;, line 118, in dbapi
      return __import__(&quot;MySQLdb&quot;)
    File &quot;/home/jhonig/ttx/venv/lib/python3.8/site-packages/MySQLdb/__init__.py&quot;, line 18, in &lt;module&gt;
      from . import _mysql
  ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: cannot allocate memory in static TLS block
  </code></pre>