Entrypoint modules are being loaded twice
Ever since 2306ca8df7ee, modules registered via entrypoints
# mypackage-1.2.3.dist-info/entry-points.txt
[trytond.modules]
mytrytondmodule = my.python.module
are loaded twice.
This betrays a basic expectation for python developers about the amount of times their module-level source code will be executed, creates a strange import path and crashes any use of trytond.cache.Cache
within those modules!
This is because the introduced epoint.load()
instruction will execute the module-level code but won't register it yet in the python import machinery. Subsequently, when Pool.start()
is run in any Tryton CLI or WSGI app, the module-level code will be execute first when creating the module graph and later again when actually importing the module.
Edited by Ningú