Skip to content
Advertisement

Tag: synchronization

How to call synchronous function(s) from async functions in safe manner

What can occur if one or more workers call ‘Synchronous function’ simultaneously ? Maybe one or more workers become blocked for a while ? Answer Short answer: If you call a synchronous (blocking) function from within an async coroutine, all the tasks that are concurrently running in the loop will stall until this function returns. Use loop.run_in_executor(…) to asynchronous run

Monitor thread synchronization in python

Is there any way to use monitor thread synchronization like java methods synchronization,in python class to ensure thread safety and avoid race condition? I want a monitor like synchronization mechanism that allows only one method call in my class or object Answer You might want to have a look at python threading interface. For simple mutual exclusion functionality you might

Advertisement