The problem is as follows. I have a telegram bot written to process requests. They are displayed as a message with Inline buttons in a group of several people. And there is a problem that the handler is triggered, when pressing one button at the same time, several times, which is wrong. When it works correctly, the user clicks the button, the appropriate actions are performed (database queries, etc.), the button is removed from the list and this message is updated.
How can I fix the problem with simultaneous clicking?
enter image description here
I’ve tried using a global variable to determine if the button is pressed or not, but it doesn’t work as it should. Maybe this is where using Lock from asyncio comes in handy?