Code: Select all
threading.ThreadCode: Select all
g_lock = threading.Lock()
def my_threaded_functionality():
try:
g_lock.acquire()
# ... Do something with a shared resource ...
finally:
g_lock.release()
Post by Anonymous »
Code: Select all
threading.ThreadCode: Select all
g_lock = threading.Lock()
def my_threaded_functionality():
try:
g_lock.acquire()
# ... Do something with a shared resource ...
finally:
g_lock.release()
1744646538
Anonymous
Ich habe einen Python -Dienst, der Pythons virtuelle Threads verwendet ([code]threading.Thread[/code]) Anfragen umgehen. Es gibt eine gemeinsame Singleton -Funktionalität, auf die alle Threads zugreifen möchten, was mit Threading geschützt ist.[code]g_lock = threading.Lock()
def my_threaded_functionality():
try:
g_lock.acquire()
# ... Do something with a shared resource ...
finally:
g_lock.release()
[/code]
In den Dokumenten von Threading.lock.acquire gibt es keine Fairness. Sie sind angekommen, ich würde mich für die Sperre von Asyncio entscheiden, wenn sie nicht erwähnten, dass die Schlösser nicht sicher sind. Die Frage ist, ob es sich auch um ein [url=viewtopic.php?t=20324]Problem[/url] mit Pythons virtuellen "Threads" handeln sollte.

Powered by phpBB® Forum Software © phpBB Limited
Time: 0.124s | Peak Memory Usage: 2.39 MiB | GZIP: On