문제

Is there any difference between threading.Lock(), threading.Semaphore() behaviour in usual python thread and greenthread (eventlet)?

도움이 되었습니까?

해결책

There is no difference in the behavior. However, green thread isn't actually a thread since it runs all its tasks in a single OS thread, so the threading.Lock and threading.Semaphore will behave as if it's being locked and unlocked from a single thread.

This means if you try to acquire a locked Lock or an zeroed Semaphore when using green threads, then the whole program will block forever (or until the specified timeout). Also, an RLock can only be released from the same thread it's locked, since green threads actually all run on the same thread you will be able to release an RLock from a different green thread.

In short, don't use threading locks when using green threads.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top