Error message on startup: Warning: a callable with the name 'X' has already been registered. This is probably not what you want

This looks like a false positive after implementing this feature request:

The issue I think is that your code is using absolute imports instead of relative imports in a couple of places

Changing code that looks like this:

from ServerModule1 import say_hello

to a relative import

from .ServerModule1 import say_hello

should remove those warnings.


More details:
when you do the absolute import python handles it differently to the relative import

it looks inside sys.modules for ServerModule1 which it doesn’t think it has.
(When you do the relative import it looks for MyAppName.ServerModule1 which was already loaded)

Since python doesn’t know it has the module already in memory, it goes and finds it, then re-executes the module, this leads to duplicate functions registered with the same name, hence the warnings.

3 Likes