I'm working with Python's asyncio and triing to understand the run_in_executor function with the default ThreadPoolExecutor to handle blocking tasks asynchronously. My concern is regarding accessing shared variables within these tasks.
My understanding is: When I use run_in_executor with a ThreadPoolExecutor, the tasks are executed in separate threads. Therefore, to ensure thread safety and prevent race conditions, I should use synchronization primitives like locks when accessing shared variables, just as I would with the threading module.
Is my understanding correct, or does asyncio handle shared variables differently in this context?