Correct use of hass object

I’ve started developing a custom-component (link) to integrate Meross devices’ switch and sensor capabilities to HA.

I studied the documentation and took inspiration from similar implementations (e.g. for sonoff devices).

I’m experiencing a lot of custom-component freezes (while lovelace UI continue to work properly) and I think it is due to the way I use hass object.

I learned that everything that is related to the custom-component domain should be stored and shared in the hass[DOMAIN] dict.

Since I use a blocking external library to interact with the physical devices I implemented a Thread main loop that interacts with the library and updates the hass[DOMAIN] dict with updated information (e.g. switch status, devices availability, electricity info, etc.).

Do I have to implement any locking strategy to access (read/write) the hass object?
Can I be sure that there is no possibility to have a deadlock access to it that freezes the system?

Regards,
Vincenzo