uWSGI: can't find trytond.application.app

345 views
Skip to first unread message

PMan

unread,
Oct 24, 2017, 4:15:07 PM10/24/17
to tryton
Greetings;

I have successfully started the standalone trytond, and now I am trying to run trytond behind uWSGI. My environment:
Postgres 9.6
Python 3.6
trytond 4.4.1
sao 4.4.1
uwsgi (installed via pip3) 2.0.15

Here is the iwsgi .ini file (tryton.ini):

[uwsgi]
uid = user
gid = user
master = True # start in master mode
http = :8000
# bind to port 8000
workers = 1
# run 4 worker processes
virtualenv = /opt/Tryton
file = /opt/Tryton/trytond-4.4.4/trytond/application.py
env = TRYTOND_CONFIG = /opt/Tryton/etc/trytond.conf
chdir = /opt/Tryton/trytond-4.4.4/trytond

Here is trytond.conf:

# /etc/tryton/trytond.conf - Configuration file for Tryton Server
# (trytond, trytond-admin, trytond-cron)

[web]
# Settings for the web interface

# The IP/host and port number of the interface
listen = localhost:8000

# The hostname for this interface
#hostname =

# The root path to retrieve data for GET requests
root = /opt/Tryton/sao-4.4.4


[database]
# Database related settings

# The URI to connect to the SQL database (following RFC-3986)
uri = PostgreSQL://username:'password'@localhost:5432

# The path to the directory where the Tryton Server stores files.
# The server must have write permissions to this directory.
# (Internal default: /var/lib/trytond)
path = /opt/Tryton/var/lib/files

[session]
# Session settings

# The time (in seconds) until an inactive session expires
timeout = 300

When I start uwsgi, I get the following errors:

(Tryton) root@host [/opt/Tryton]# /opt/python36/bin/uwsgi /opt/Tryton/etc/tryton.ini
[uWSGI] getting INI configuration from /opt/Tryton/etc/tryton.ini
*** Starting uWSGI 2.0.15 (64bit) on [Tue Oct 24 15:53:37 2017] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-16) on 05 October 2017 22:04:37
os: Linux-3.10.0-714.10.2.lve1.4.63.el7.x86_64 #1 SMP Sun Aug 20 17:46:23 EDT 2017
nodename: host.mysite.com
machine: x86_64
clock source: unix
pcre jit disabled
current working directory: /opt/Tryton
detected binary path: /opt/python36/bin/uwsgi
setgid() to group
setuid() to user
chdir() to /opt/Tryton/trytond-4.4.4/trytond
your processes number limit is 14335
your memory page size is 4096 bytes
detected max file descriptor number: 4096
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8000 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:23274 (port auto-assigned) fd 3
Python version: 3.6.2 (default, Aug 5 2017, 01:12:58) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
PEP 405 virtualenv detected: /opt/Tryton
Set PythonHome to /opt/Tryton
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x14f9980
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145536 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
/opt/Tryton/lib/python3.6/site-packages/trytond-4.4.4-py3.6.egg/trytond/modules/__init__.py:143: DeprecationWarning: This method will be removed in future versions. Use 'parser.read_file()' instead.
module_config.readfp(fp)
unable to find "application" callable in file /opt/Tryton/trytond-4.4.4/trytond/application.py
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1210)
spawned uWSGI worker 1 (pid: 1212, cores: 1)
spawned uWSGI http 1 (pid: 1213)
^CSIGINT/SIGQUIT received...killing workers...
gateway "uWSGI http 1" has been buried (pid: 1213)
worker 1 buried after 1 seconds
goodbye to uWSGI.
(Tryton) root@host [/opt/Tryton]#

Cédric Krier

unread,
Oct 25, 2017, 4:50:06 AM10/25/17
to tryton
On 2017-10-24 13:00, PMan wrote:
> Python version: 3.6.2 (default, Aug 5 2017, 01:12:58) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
> PEP 405 virtualenv detected: /opt/Tryton
> Set PythonHome to /opt/Tryton
> *** Python threads support is disabled. You can enable it with --enable-threads ***

It seems you do not have thread on your Python. Tryton uses threading
module. I do not know if it may be the problem.

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

PMan

unread,
Oct 25, 2017, 6:45:07 PM10/25/17
to tryton
Thank you.

I enabled threads in the .ini file but I got the same results:

(Tryton) root@host [/opt/Tryton]# /opt/python36/bin/uwsgi /opt/Tryton/etc/tryton.ini
[uWSGI] getting INI configuration from /opt/Tryton/etc/tryton.ini
*** Starting uWSGI 2.0.15 (64bit) on [Wed Oct 25 16:13:07 2017] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-16) on 05 October 2017 22:04:37
os: Linux-3.10.0-714.10.2.lve1.4.63.el7.x86_64 #1 SMP Sun Aug 20 17:46:23 EDT 2017
nodename: host.mysite.com
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /opt/Tryton
detected binary path: /opt/python36/bin/uwsgi
setgid() to group
setuid() to user
chdir() to /opt/Tryton/trytond-4.4.4/trytond
your processes number limit is 14335
your memory page size is 4096 bytes
detected max file descriptor number: 4096
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8000 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:29116 (port auto-assigned) fd 3
Python version: 3.6.2 (default, Aug 5 2017, 01:12:58) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
PEP 405 virtualenv detected: /opt/Tryton
Set PythonHome to /opt/Tryton
Python main interpreter initialized at 0x1eeb9f0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 166144 bytes (162 KB) for 2 cores
*** Operational MODE: threaded ***
/opt/Tryton/lib/python3.6/site-packages/trytond-4.4.4-py3.6.egg/trytond/modules/__init__.py:143: DeprecationWarning: This method will be removed in future versions. Use 'parser.read_file()' instead.
module_config.readfp(fp)
unable to find "application" callable in file /opt/Tryton/trytond-4.4.4/trytond/application.py
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1339)
spawned uWSGI worker 1 (pid: 1341, cores: 2)
spawned uWSGI http 1 (pid: 1342)
^CSIGINT/SIGQUIT received...killing workers...
gateway "uWSGI http 1" has been buried (pid: 1342)
worker 1 buried after 1 seconds
goodbye to uWSGI.
(Tryton) root@host [/opt/Tryton]#

Maybe it doens't matter, but it seems odd that it's running /opt/Tryton/lib/python3.6/site-packages/trytond-4.4.4-py3.6.egg/trytond/modules/__init__.py instead of /opt/Tryton/trytond-4.4.4/trytond/modules/__init__.py.

Regards,
Paul

Cédric Krier

unread,
Oct 25, 2017, 8:26:03 PM10/25/17
to tryton
On 2017-10-25 15:39, PMan wrote:
> Thank you.
>
> I enabled threads in the .ini file but I got the same results:

So you can probably re-disable it.
So here it does not find the object to call.
It should be app. I guess you must configure: mountpoint='app' but I can
not confirm because I can not understand the uwsgi documentation.

> *** no app loaded. going in full dynamic mode ***
> *** uWSGI is running in multiple interpreter mode ***
> spawned uWSGI master process (pid: 1339)
> spawned uWSGI worker 1 (pid: 1341, cores: 2)
> spawned uWSGI http 1 (pid: 1342)
> ^CSIGINT/SIGQUIT received...killing workers...
> gateway "uWSGI http 1" has been buried (pid: 1342)
> worker 1 buried after 1 seconds
> goodbye to uWSGI.
> (Tryton) root@host [/opt/Tryton]#
>
> Maybe it doens't matter, but it seems odd that it's running /opt/Tryton/lib/python3.6/site-packages/trytond-4.4.4-py3.6.egg/trytond/modules/__init__.py instead of /opt/Tryton/trytond-4.4.4/trytond/modules/__init__.py.
>
> Regards,
> Paul

Sergi Almacellas Abellana

unread,
Oct 26, 2017, 3:19:42 AM10/26/17
to try...@googlegroups.com
El 26/10/17 a les 02:16, Cédric Krier ha escrit:
You should use trytond.mapplication:app as uwsgi module to load. Here is
a minimal configuration that works for us:

[uwsgi]

http-socket=0.0.0.0:8000

module=trytond.application:app

Hope it helps.



--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

PMan

unread,
Oct 26, 2017, 7:10:08 PM10/26/17
to tryton
Thanks Cedric, I will leave threads enabled for now.

Thank you Sergi, I tried that configuration, but got the same results.

The only file in the trytond-4.4.4/trytond/modules directory is __init__.py.

Here is the error:

(Tryton) root@host [/opt/Tryton]# /opt/python36/bin/uwsgi --ini /opt/Tryton/etc/tryton.ini
[uWSGI] getting INI configuration from /opt/Tryton/etc/tryton.ini
*** Starting uWSGI 2.0.15 (64bit) on [Thu Oct 26 16:27:50 2017] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-16) on 05 October 2017 22:04:37
os: Linux-3.10.0-714.10.2.lve1.4.63.el7.x86_64 #1 SMP Sun Aug 20 17:46:23 EDT 2017
nodename: host.mysite.com
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /opt/Tryton
detected binary path: /opt/python36/bin/uwsgi
setgid() to group
setuid() to user
chdir() to /opt/Tryton/trytond-4.4.4/trytond
your processes number limit is 14335
your memory page size is 4096 bytes
detected max file descriptor number: 4096
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:8000 fd 3
Python version: 3.6.2 (default, Aug 5 2017, 01:12:58) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
PEP 405 virtualenv detected: /opt/Tryton
Set PythonHome to /opt/Tryton
Python main interpreter initialized at 0x953960
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 166144 bytes (162 KB) for 2 cores
*** Operational MODE: threaded ***
/opt/Tryton/lib/python3.6/site-packages/trytond-4.4.4-py3.6.egg/trytond/modules/__init__.py:143: DeprecationWarning: This method will be removed in future versions. Use 'parser.read_file()' instead.
module_config.readfp(fp)
ModuleNotFoundError: No module named 'trytond.application.app'; 'trytond.application' is not a package
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 826)
spawned uWSGI worker 1 (pid: 828, cores: 2)
^CSIGINT/SIGQUIT received...killing workers...
worker 1 buried after 1 seconds
goodbye to uWSGI.
(Tryton) root@host [/opt/Tryton]#

Here is the tryton.ini file (with threads enabled):

[uwsgi]
uid = user
gid = group
master = True # start in master mode
http-socket = 127.0.0.1:8000
# bind to port 8000
enable-threads = true
workers = 1
threads = 2

virtualenv = /opt/Tryton
# chdir = /opt/Tryton/trytond-4.4.4/trytond
module = trytond.application.app
env = TRYTOND_CONFIG = /opt/Tryton/etc/trytond.conf

I tried this with the chdir command commented and uncommented, I got the same results.

Regards,
Paul

Sergi Almacellas Abellana

unread,
Oct 27, 2017, 3:00:06 AM10/27/17
to try...@googlegroups.com
El 26/10/17 a les 22:49, PMan ha escrit:
> Here is the tryton.ini file (with threads enabled):
>
> [uwsgi]
> uid = user
> gid = group
> master = True # start in master mode
> http-socket = 127.0.0.1:8000
> # bind to port 8000
> enable-threads = true
> workers = 1
> threads = 2
>
> virtualenv = /opt/Tryton
> # chdir = /opt/Tryton/trytond-4.4.4/trytond
> module = trytond.application.app
> env = TRYTOND_CONFIG = /opt/Tryton/etc/trytond.conf
>
> I tried this with the chdir command commented and uncommented, I got the same results.

For me it seems that trytond is not properly installed on the virtualenv
(and that's why it's not found)

How you installed it? Are you sure you've created the virtualenv in
/opt/Tryton ?

PMan

unread,
Oct 28, 2017, 10:55:08 AM10/28/17
to tryton
@Sergi:
I installed trytond by:
- downloading and expanding the source inside the virtual environment
- activating the virtual environment, and then
- python setup.py install

After reading your post, I stored my config files, deleted the virtual environment, and started over.
1 Created the virtual environment /opt/Tryton
2 activated it (when activated, python -V returns python 3.6.2)
3 installed trytond with pip ./bin/pip3 install trytond
4 restored the config files to /opt/Trytond/etc

I can run tryton without uwsgi:
"./bin/trytond -c /opt/Tryton/etc/trytond.conf " from the command line, there are no errors. I did not try to access the instance, but it did start.

I still cannot run tryton with uwsgi:
I install uwsgi with pip. uwsgi is in the /opt/python36/bin folder, it was not installed in the virtual environment.

"/opt/python36/bin/uwsgi --ini /opt/Tryton/etc/tryton.ini" from the command line produces the exact same errors I posted before.

In /opt/Tryton/lib/python3.6/site-packages/trytond there is a file application.py

In /opt/Tryton/lib/python3.6/site-packages/trytond/modules there is a file __init__.py, and a directory, pycache.

Here is the output, in case I missed something:
/opt/python36/bin/uwsgi --ini /opt/Tryton/etc/tryton.ini
[uWSGI] getting INI configuration from /opt/Tryton/etc/tryton.ini
*** Starting uWSGI 2.0.15 (64bit) on [Sat Oct 28 10:38:11 2017] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-16) on 05 October 2017 22:04:37
os: Linux-3.10.0-714.10.2.lve1.4.63.el7.x86_64 #1 SMP Sun Aug 20 17:46:23 EDT 2017
nodename: host.mysite.com
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /opt/Tryton
detected binary path: /opt/python36/bin/uwsgi
setgid() to group
setuid() to user
your processes number limit is 14335
your memory page size is 4096 bytes
detected max file descriptor number: 4096
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:8000 fd 3
Python version: 3.6.2 (default, Aug 5 2017, 01:12:58) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
PEP 405 virtualenv detected: /opt/Tryton
Set PythonHome to /opt/Tryton
Python main interpreter initialized at 0xb51930
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 166144 bytes (162 KB) for 2 cores
*** Operational MODE: threaded ***
/opt/Tryton/lib/python3.6/site-packages/trytond/modules/__init__.py:143: DeprecationWarning: This method will be removed in future versions. Use 'parser.read_file()' instead.
module_config.readfp(fp)
ModuleNotFoundError: No module named 'trytond.application.app'; 'trytond.application' is not a package
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 13598)
spawned uWSGI worker 1 (pid: 13600, cores: 2)

Cédric Krier

unread,
Oct 28, 2017, 11:20:05 AM10/28/17
to tryton
On 2017-10-28 07:40, PMan wrote:
> ModuleNotFoundError: No module named 'trytond.application.app'; 'trytond.application' is not a package

The is a configuration problem, it should not try to import
trytond.application.app but it should run app in trytond.application.
I do not know uwsgi configuration syntax but usually it is:

trytond.application:app

PMan

unread,
Oct 29, 2017, 5:00:08 AM10/29/17
to tryton
@Cedric:
Thank you, that did it. In the docs here:
http://doc.tryton.org/4.4/trytond/doc/topics/start_server.html
it says " you can use the application trytond.application.app" That has a period '.' between application and app, but what is required is a colon ':'.

uwsgi starts without errors now.

Thank you all!

Cédric Krier

unread,
Oct 29, 2017, 5:30:06 AM10/29/17
to tryton
On 2017-10-28 20:07, PMan wrote:
> @Cedric:
> Thank you, that did it. In the docs here:
> http://doc.tryton.org/4.4/trytond/doc/topics/start_server.html
> it says " you can use the application trytond.application.app" That
> has a period '.' between application and app, but what is required is
> a colon ':'.

The documentation shows the qualified name for the application. The need
to use colon is a particularity of uwsgi (but also some other
applications). But I think we should use the Python standard format in
the documentation.
Reply all
Reply to author
Forward
0 new messages