One hurdle of developing multi-threaded IDAPython scripts is safely reading from and writing to the database. IDA asks that you execute functions that may read or write in the main thread using the idaapi.execute_sync function. This function schedules the function object (the first parameter) to run at a time that is safe to access the database.
I’ve often skipped this bookkeeping and hoped for the best, since it can be tedious to marshal function object and sprinkle idaapi.execute_sync everwhere. To make things painless, try using the following decorators to annotate functions that may read from or write to the IDB:
For example, here’s a script that safely resets the name of the function at 0x401000: