Enqueue or delay HA entity control calls - HOW?!

Hello!
I’m working on a custom component for a new integration which communicates to a gateway of a smart home system via TCP socket. I’m almost done with it, but when I started wider testing I discovered a major problem. When I execute a scene or control a group of entities (e.g. with a light group switch in GUI) HA sends the control commands so fast, that the gateway I sent my TCP queries to is not able to process them all and looses some of them. As a result some lights are not switched on/off.

Question: how to solve such an issue?? In HA everything is async and happens in parallel. In my log I see that the control commands are sent from HA using 3 different ‘threads’ (sync workers):
See below:

2019-11-11 16:18:29 DEBUG (SyncWorker_9) [custom_components.extalife.pyextalife] TCP command to execute: b'{"command": 20, "data": {"id": 0, "channel": 1, "state": 1, "value": 32}}\x03'
2019-11-11 16:18:29 DEBUG (SyncWorker_4) [custom_components.extalife.pyextalife] TCP command to execute: b'{"command": 20, "data": {"id": 5, "channel": 1, "state": 1, "value": 0}}\x03'
2019-11-11 16:18:29 DEBUG (SyncWorker_2) [custom_components.extalife.pyextalife] TCP command to execute: b'{"command": 20, "data": {"id": 14, "channel": 1, "state": 1, "value": 27}}\x03'

I guess I either need to enqueue these calls somehow and execute them sequentially or have some bigger delay between them to allow the gateway to process them and be ready to receive the next ones.

Right now I have no clue how to solve this. Any suggestions from your side guys?

PS. My component is synchronous as I’m too new to Python and asyncio and HA to be able to make it async.

OK, I found a way, but not sure if this is thread safe or will have some side effects.
I wrote a very simple dispatcher class with a static method:

class ActionDispatcher():

    _busy = False

    @classmethod
    def exec_action(cls, callback, action, **params):
        import time

        while cls._busy:
            time.sleep(0.2)

        cls._busy = True
        resp = callback(action, **params)
        cls._busy = False

        return resp

And when my base entity class is called to perform an action (currently the method that calls TCP socket is called ‘action2’ I call it like this"

ActionDispatcher.exec_action(self.action2, action, **add_pars)

Any comments are most welcome.