I try to encourage Lona users to use callback based input event handler to make their apps more scaleable, but currently input event handler run serialized.
Let's say we have two buttons. The first button triggers a long running operation (getting a value from a database), the second triggers a short running operation (toggling a popup). When the first button is pressed the popup can't be opened or closed, until get_count_from_database() is done. For the end-user the app then feels slow and unresponsive.
from lona.html import HTML, H1, Span, Button
from lona import LonaView
from my_code import long_running_database_call, Modal
class MyLonaView(LonaView):
def get_count_from_database(self, input_event):
self.count = long_running_database_call()
def toggle_modal(self, input_event):
self.modal.toggle()
def handle_request(self, request):
self.counter = Span()
self.modal = Modal()
return HTML(
H1('The count from the database is: ', self.counter),
self.modal,
Button(
'Get count from Database',
handle_click=self.get_count_from_database,
),
Button(
'Toggle modal',
handle_click=self.toggle_modal,
)
)
You can solve this issue by runnnig get_count_from_database() in a thread, but i think we can automate this.
My idea is to allow parallel execution of input event handlers in the server, but very limited. I think we can't just use a thread for every click a user makes (that would be ascalability nightmare), but we can make the count of parallel input event handler configurable in the settings.
I would propose 2 as default. With two parallel handlers you can run one long running call and service input like button presses, without handling threading by yourself.
@SmithChart, @maratori, @grigolet, @laundmo, @korantu
I try to encourage Lona users to use callback based input event handler to make their apps more scaleable, but currently input event handler run serialized.
Let's say we have two buttons. The first button triggers a long running operation (getting a value from a database), the second triggers a short running operation (toggling a popup). When the first button is pressed the popup can't be opened or closed, until
get_count_from_database()is done. For the end-user the app then feels slow and unresponsive.You can solve this issue by runnnig
get_count_from_database()in a thread, but i think we can automate this.My idea is to allow parallel execution of input event handlers in the server, but very limited. I think we can't just use a thread for every click a user makes (that would be ascalability nightmare), but we can make the count of parallel input event handler configurable in the settings.
I would propose
2as default. With two parallel handlers you can run one long running call and service input like button presses, without handling threading by yourself.@SmithChart, @maratori, @grigolet, @laundmo, @korantu