I need some guidance with optimising my Python project.
This is an internal project for our support team to query the database and get information through a GUI for common support issues, rather than writing SQL / calling the API with Postman etc.
This tool accesses and updates data using SQL (pyodbc) Mongo DB (pymongo), REST API (requests).
I have found it relatively fast for the most part up until recently when I am finding now that my javascript calls to these functions are taking a very long time to even start.
An example of a function in Python:
@eel.expose def list_settings(): data = [] settings = db.list_sc_settings() for s in settings: data.append({ "Setting Key": s.skey, "Setting Value": s.sval }) return data
An example of the JS calling the function
eel.list_settings()(function(res) { html += '<form id="settings"' html += "<div class='row'>" html += "<div class='col-sm-6 fields'>" res.forEach(r => { html += '<div class="mb-3">' html += ' <label for="productname">' + r["Setting Key"] + '</label>' html += '<input id="' + r["Setting Key"] + '" name="' + r["Setting Key"] + '" type="text" class="form-control" value="' + r["Setting Value"] html += '">' html += '</div>' }) html += "</div>" html += "</div>" html += '<div class="d-flex flex-wrap gap-2">' html += '<button type="submit" id="saveSettings" class="btn btn-primary waves-effect waves-light">Save Changes</button>' html += '<button type="button" id="clearForm" class="btn btn-secondary waves-effect waves-light">Reset</button>' html += '</div>' html += "</form>" $(".card-body .card-title-desc").after(html) $("#clearForm").click(function() { get_settings() }) $("#saveSettings").click(function() { $(".mb-3 input").each(function(e) { skey = $(this).first("input").attr("name") sval = $(this).first("input").val() eel.update_sc_setting(skey, sval) }) toastr.success("Settings updated") })
When I try and call any of the functions now it takes a while for it to even start the process - it will eventually start but it will take several minutes each time.
Where have I gone wrong?
Also possibly related ? I have a lot of (minified) JS libraries used for the UI as well, will this cause issues?
I need some guidance with optimising my Python project.
This is an internal project for our support team to query the database and get information through a GUI for common support issues, rather than writing SQL / calling the API with Postman etc. This tool accesses and updates data using SQL (pyodbc) Mongo DB (pymongo), REST API (requests).
I have found it relatively fast for the most part up until recently when I am finding now that my javascript calls to these functions are taking a very long time to even start.
An example of a function in Python:
@eel.expose def list_settings(): data = [] settings = db.list_sc_settings() for s in settings: data.append({ "Setting Key": s.skey, "Setting Value": s.sval }) return data
An example of the JS calling the function
eel.list_settings()(function(res) { html += '<form id="settings"' html += "<div class='row'>" html += "<div class='col-sm-6 fields'>" res.forEach(r => { html += '<div class="mb-3">' html += ' <label for="productname">' + r["Setting Key"] + '</label>' html += '<input id="' + r["Setting Key"] + '" name="' + r["Setting Key"] + '" type="text" class="form-control" value="' + r["Setting Value"] html += '">' html += '</div>' }) html += "</div>" html += "</div>" html += '<div class="d-flex flex-wrap gap-2">' html += '<button type="submit" id="saveSettings" class="btn btn-primary waves-effect waves-light">Save Changes</button>' html += '<button type="button" id="clearForm" class="btn btn-secondary waves-effect waves-light">Reset</button>' html += '</div>' html += "</form>" $(".card-body .card-title-desc").after(html) $("#clearForm").click(function() { get_settings() }) $("#saveSettings").click(function() { $(".mb-3 input").each(function(e) { skey = $(this).first("input").attr("name") sval = $(this).first("input").val() eel.update_sc_setting(skey, sval) }) toastr.success("Settings updated") })
When I try and call any of the functions now it takes a while for it to even start the process - it will eventually start but it will take several minutes each time.
Where have I gone wrong? Also possibly related ? I have a lot of (minified) JS libraries used for the UI as well, will this cause issues?