ajwdev
ajwdev

Reputation: 1182

Eventlet and locking

Since Eventlet uses green threading and asynchronous I/O, do I still need to set locks before accessing objects? My understanding is that greenlets are all part of one thread and locking isn't necessary. Can anyone confirm or deny this?

Upvotes: 4

Views: 1887

Answers (1)

Alex Martelli
Alex Martelli

Reputation: 882103

Your understanding is correct: "green" threads are not actually threads, they don't get pre-empted at unpredictable points (esp. not "in the middle" of an operation), so you have full control of when execution moves away from one (and can thus get dispatched to another) and can save yourself the trouble/overhead of lock acquire/release operations.

Upvotes: 7

Related Questions