Python 3.14 gemeinsame Mutex-SperrePython

Python-Programme
Anonymous
 Python 3.14 gemeinsame Mutex-Sperre

Post by Anonymous »

Ich versuche, einen gemeinsam genutzten Mutex in Python (ala C++ shared_mutex) zu erstellen, damit mehrere Threads eine Variable lesen können, während ein Thread eine exklusive Sperre erhalten kann (alle Leser blockieren), während er die Variable(n) ändert, und dann allen Leser-Threads erlauben kann, zum Lesen auf die Variable zuzugreifen. Ich finde nicht viel mit KI, und die Python-Dokumentation scheint nicht zu sagen, dass dies eine Möglichkeit ist. Gibt es eine Problemumgehung oder eine Möglichkeit, einen gemeinsamen Mutex zu „fälschen“?
Der Pseudocode würde in etwa so aussehen (in separaten Threads) -

Code: Select all

1 thread:
with self.__lock('exclusive'):
self.__var = True

all other threads:
with self.__lock('shared'):
x = self.__var

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post
  • Python 3.14 gemeinsame Mutex-Sperre
    by Anonymous » » in Python
    0 Replies
    1 Views
    Last post by Anonymous
  • Python 3.14 gemeinsame Mutex-Sperre
    by Anonymous » » in Python
    0 Replies
    0 Views
    Last post by Anonymous
  • Python 3.14 gemeinsame Mutex-Sperre
    by Anonymous » » in Python
    0 Replies
    1 Views
    Last post by Anonymous
  • Kann ein einfacher Mutex pthread_mutex ein Ersatz für GIL in einer Multithread-Python-C-Erweiterung sein?
    by Guest » » in Python
    0 Replies
    51 Views
    Last post by Guest
  • Python mutex.cc Lock -Problem
    by Anonymous » » in Python
    0 Replies
    15 Views
    Last post by Anonymous