Home > other >  Python - SQLAlchemy random errors
Python - SQLAlchemy random errors

Time:10-13

I'm using nginx, uwsgi and SQLAlchemy Settings. I switch from SQLObject recently, now I see strange random errors SQLAlchemy. For example:

Sqlalchemy. Exc. ResourceClosedError: This result object does not return rows. It has had been closed automatically.

Or:

Sqlalchemy. Exc. NoSuchColumnError: "Could not locate the column in a row for the column 'module. Id'"

This is a kind of I don't know of SQLAlchemy behavior? It can be associated with multiple processes/threads in uwsgi?
My uwsgi configuration file is shown below:

[uwsgi]
The plugins=python
The socket=127.0.0.1:9002
Wsgi - file=/thesystem/code/API. Py
Master=True
The processes=4
Threads=2
Daemonize=/thesystem/logs/uwsgi log
Pidfile=/thesystem/uwsgi. Pid

CodePudding user response:

You probably is in thesystem/code/API py entry points to open the connection.
This means that your file descriptor will inherit in the worker, this does not apply to sqlalchemy.
Add in your ini configuration - lazy - apps (lazy - apps=true), in each worker load/thesystem/code/API. Py, rather than automatically in the master it then calls the fork ()

CodePudding user response:

The mistake I have met in the process of development, now has been solved, can have a look at my article
https://blog.csdn.net/liuhuanchao/article/details/103639298
  • Related