Remove stack allocated lock acquisition - #47
Conversation
This change should not affect behavior. These locks aren't declared outside stack scope so there is no means by which another thread could attempt to acquire the same lock.
CCP-Aporia
left a comment
There was a problem hiding this comment.
Interesting! So, threading.Lock() was indeed wrong here. However, now the class is no longer thread-safe. A likely use case is that this kind of class is used to communicate between threads - a use-case that is supported by Stackless' channel implementation. Without any kind of lock - or with the previous stack-based lock - then this is going to cause data races.
Don't python threads require a GIL acquisition? If so, there can only ever be a single thread executing python bytecode at any time. https://docs.python.org/3/library/threading.html#gil-and-performance-considerations I can see a case where we might want to add a locking mechanism here for free-threaded builds. |
This change should not affect behavior. These locks aren't declared outside stack scope so there is no means by which another thread could attempt to acquire the same lock.
Summary
AI assistance disclosure
None
Type of change
Linked issue (optional)
No linked issue. But a question was brough up here which resulted in this work.
What changed
QueueChannelobjects.Testing
Platforms tested
Screenshots / captures
Checklist