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

What I’m trying to do:
I don’t think I changed any relevant code, but now I’m getting a printout whenever I start my app as follows:

Warning: a callable with the name 'http-wellknown:/apple-developer-merchantid-domain-association' has already been registered. This is probably not what you want

Warning: a callable with the name 'add_info' has already been registered. This is probably not what you want

Warning: a callable with the name 'delete_merge_learning_card' has already been registered. This is probably not what you want

Warning: a callable with the name 'create_learning_card' has already been registered. This is probably not what you want

Warning: a callable with the name 'get_user_lc_groups' has already been registered. This is probably not what you want

Warning: a callable with the name 'get_learning_cards' has already been registered. This is probably not what you want

Warning: a callable with the name 'update_learning_card' has already been registered. This is probably not what you want

Warning: a callable with the name 'get_num_learning_cards' has already been registered. This is probably not what you want

Warning: a callable with the name 'get_user_most_recent_valid_session_id' has already been registered. This is probably not what you want

Warning: a callable with the name 'ai_text_generated' has already been registered. This is probably not what you want

Warning: a callable with the name 'assign_session_to_user' has already been registered. This is probably not what you want

Warning: a callable with the name 'http:/policy' has already been registered. This is probably not what you want

Warning: a callable with the name 'launch_my_background_task' has already been registered. This is probably not what you want

Warning: a callable with the name 'get_highest_page_number' has already been registered. This is probably not what you want

Warning: a callable with the name 'get_session_pdf_url' has already been registered. This is probably not what you want

Warning: a callable with the name 'handle_ai_still_generating' has already been registered. This is probably not what you want

Warning: a callable with the name 'add_generation_task_id' has already been registered. This is probably not what you want

Warning: a callable with the name 'add_ai_task_id' has already been registered. This is probably not what you want

Warning: a callable with the name 'get_pdf_upload_view' has already been registered. This is probably not what you want

Warning: a callable with the name 'get_session_data_table' has already been registered. This is probably not what you want

Warning: a callable with the name 'force_login_user' has already been registered. This is probably not what you want

Warning: a callable with the name 'get_user_emails' has already been registered. This is probably not what you want

Warning: a callable with the name 'find_pricing_plan' has already been registered. This is probably not what you want

Warning: a callable with the name 'create_new_stripe_customer' has already been registered. This is probably not what you want

Warning: a callable with the name 'create_stripe_checkout_session' has already been registered. This is probably not what you want

Warning: a callable with the name 'process_stripe_checkout_session_status' has already been registered. This is probably not what you want

Warning: a callable with the name 'get_stripe_customer_portal_url' has already been registered. This is probably not what you want

Warning: a callable with the name 'http:/stripe_webhooks' has already been registered. This is probably not what you want

Warning: a callable with the name 'task:process_stripe_event' has already been registered. This is probably not what you want

Warning: a callable with the name 'deal_with_user_proration_request' has already been registered. This is probably not what you want

Warning: a callable with the name 'get_user_info' has already been registered. This is probably not what you want

Warning: a callable with the name 'add_user_to_free_plan' has already been registered. This is probably not what you want

Warning: a callable with the name 'sign_up_user' has already been registered. This is probably not what you want

Warning: a callable with the name 'serverside_error_handler' has already been registered. This is probably not what you want

The only change I’ve made is switched from this import:
from sentence_transformers import SentenceTransformer, util

to this import:
from transformers import AutoTokenizer, AutoModel, AutoModelForSequenceClassification
import torch
import torch.nn.functional as F

Any thoughts? :slight_smile:

Do any of those functions happen to be defined in the files of the new imports? Or maybe they’re imported in those files too?

I don’t think so. They are very much my own functions and I am also getting an error for every single one my callables (32 of them) + for two http ones i dont have, namely: http-wellknown:/apple-developer-merchantid-domain-association and http:/policy

There’s no way someone has a deal_with_user_proration_request or get_user_most_recent_valid_session_id AND all my other functions exactly.

I also havent made this app publicly available for someone to use as a dependency, if that could be a thing.

1 Like

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

Hi,
I am having a similar problem - my app logs are flooded with repeated sets of warning messages each set containing a warning for every function in my Servermodule1. I can’t find anywhere where I use absolute imports equivalent to ‘from ServerModule1 import say_hello’. Since I get multiple sets of warning messages I am guessing this has something to do with the fact I am on the Professional Plan where Persistent server is not a feature. If my guess is correct, apart from upgrading to the Business Plan (which I don’t need at the moment for any business reason), is there anything I can do to stop this happening?

Regards
Steve

Worth double checking your app. I suspect you have multiple callables registered with the same name.

Take one of the warning messages and then do a global search for the name that was registered.
You might find that you have two or more such callables with those names.


Sidenote:

There is one false positive we’ve identified when callables are decorated with @anvil.tables.in_transaction that we’ll be fixing

changing decorators from:

@anvil.tables.in_transaction
@anvil.server.callable
def my_func():
    ...

to

@anvil.server.callable
@anvil.tables.in_transaction
def my_func():
    ...

should fix those false positives

Hi Stucork,

Thanks for your prompt reply.

I have done global searches for every function in the list of callables in the app log and for every one it only finds one version: -

details
Warning: a callable with the name 'initialise_database_connection' has already been registered. This is probably not what you want
Warning: a callable with the name 'close_database_connection' has already been registered. This is probably not what you want
Warning: a callable with the name 'initialise_emission_factors' has already been registered. This is probably not what you want
Warning: a callable with the name 'task:upload_estate_H4_PC_001_bt' has already been registered. This is probably not what you want
Warning: a callable with the name 'task:upload_project_initialisation_data_bt' has already been registered. This is probably not what you want
Warning: a callable with the name 'export_estate_lite_upload_form_to_excel' has already been registered. This is probably not what you want
Warning: a callable with the name 'export_estate_upload_form_to_excel' has already been registered. This is probably not what you want
Warning: a callable with the name 'export_estate_upload_form_to_excel_PC_01' has already been registered. This is probably not what you want
Warning: a callable with the name 'export_project_details_form_to_excel' has already been registered. This is probably not what you want
Warning: a callable with the name 'export_project_progress_update_form_to_excel' has already been registered. This is probably not what you want
Warning: a callable with the name 'export_project_initialisation_form_to_excel' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_entity_number_v002' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_entity_name_v002' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_all_entity_codes_except_reporting_only' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_all_partner_codes' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_partner_name_number_from_id' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_client_name_number_from_id' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_entity_name_number_from_id' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_all_client_codes' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_all_entity_codes' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_user_partner_details' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_programme_start_date_v002' has already been registered. This is probably not what you want
Warning: a callable with the name 'save_programme_start_date' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_summary_stats' has already been registered. This is probably not what you want
Warning: a callable with the name 'task:upload_project_details_data_bt' has already been registered. This is probably not what you want
Warning: a callable with the name 'export_all_results' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_buildings_with_gaselec_savings_fail' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_projects_for_building_with_gaselec_savings_fail' has already been registered. This is probably not what you want
Warning: a callable with the name 'get_project_types' has already been registered. This is probably not what you want
Warning: a callable with the name 'task:upload_forecast_actual_energy_usage_bt' has already been registered. This is probably not what you want
Warning: a callable with the name 'task:upload_forecast_actual_energy_cost_bt' has already been registered. This is probably not what you want
Warning: a callable with the name 'launch_convert_pbi_tables' has already been registered. This is probably not what you want
Warning: a callable with the name 'launch_upload_estate_partner_PC_01' has already been registered. This is probably not what you want
Warning: a callable with the name 'launch_upload_project_initialisation_data_v001' has already been registered. This is probably not what you want
Warning: a callable with the name 'launch_upload_project_details_data_v001' has already been registered. This is probably not what you want
Warning: a callable with the name 'launch_upload_forecast_actual_energy_usage_v001' has already been registered. This is probably not what you want
Warning: a callable with the name 'launch_upload_forecast_actual_energy_cost_v001' has already been registered. This is probably not what you want
Warning: a callable with the name 'special_populate_hp_elec_add_kwh_pa' has already been registered. This is probably not what you want
Warning: a callable with the name 'launch_correct_task_log_dt_str' has already been registered. This is probably not what you want
Warning: a callable with the name 'test_date_rounding' has already been registered. This is probably not what you want
Warning: a callable with the name 'test_calc_projects' has already been registered. This is probably not what you want
Warning: a callable with the name 'test_get_partner_client_from_entity_number' has already been registered. This is probably not what you want
Warning: a callable with the name 'launch_migration_to_HUB4' has already been registered. This is probably not what you want
Warning: a callable with the name 'task:correct_task_log_dt_str' has already been registered. This is probably not what you want
Warning: a callable with the name 'task:migration_to_HUB4' has already been registered. This is probably not what you want
Warning: a callable with the name 'launch_latlong_migration' has already been registered. This is probably not what you want
Warning: a callable with the name 'task:convert_pbi_tables' has already been registered. This is probably not what you want
Warning: a callable with the name 'task:upload_latlong_migration_v001' has already been registered. This is probably not what you want

Regards
Steve

Any fix is always welcome, but I wanted to point out that in this case the documentation explicitly says Make sure to specify @anvil.tables.in_transaction after @anvil.server.callable.

I also wanted to point out that the fact that the documentation says it, doesn’t make it any easier to use. It would be nicer if one didn’t need to pay attention to the order, or, if the order is really important, if the console printed a warning message, something like decorator X appears after decorator Y, which is probably not what you meant, or which doesn't really work (see here for details).

2 Likes

Hi Stu,

I have restructured my Estate app to make kv_calcs a Module owned by ServerModule1 which is now a Package. Changed the location of the function in kv_calcs that needed intialialise_database_connection so no need for the import. Changed remaining import of kv_calcs to relative positioning as advised and all the warning messages have now stopped.

Thanks for your help and guidance.

Regards
Steve

1 Like

Have all the false positives of this issue been fixed?

I am still getting tons of these warnings whenever a @anvil.server.background_task function starts. Almost all code is inside of one ServerModule and I’m not importing from another module in this function.

As far as I’m aware it’s fixed. So we’ll need a little more information if you’re experiencing similar issues. If you’d like to provide an app id we can go and take a look.

1 Like