Am a java Developer and started learning python Language, recently i came across the Python Gevent Library which is uses Asynchronous greenlets. Could somebody explain me, How synchronization, Deadlocks, live lock works/avoided in Python using Gevent.
- In Java Threading, we have Synchronization blocks, which prevents the above issues
Writing concurrent applications using gevent is different from those using multithreads or multiprocesses. It allows you to write concurrent applications using synchronous logic and only one greenlet could run at a time.
If you have created many greenlets and they should visit the same resource but they don't have cooperation relationships, then you don't have to use locks to control them visiting the shared resource because there's only one greenlet could run at a time. Until the greenlet encounters some operations which could hand in the execution to the hub greenlet, it will run all the time until it returns.
If the greenlets you create have cooperation relationships, you could use locks provided by gevent as the way you use in Java.
Here's some resources which may do you a favor: