Hello,

I've been chasing down various synchronization bugs in a large codebase
I'm working on.

In the process I began to realize how useful it would be to have some
sort of descriptor (a name if you will) attached to some of my
primitives.

In this code base, I've a number of threading.Event objects that get
passed around to check for conditions.  In a perfect world, every
developer would have used the same nomenclature and been consistent
everywhere.  Alas....

Currently there isn't a great way built into the language for me to say
"which Event is this <threading.Event object at 0x7f66da73ed60> ?"
unless I already have a mapping of the addresses to variable names in
my logs.

Would a `name=` keywordonly argument for things like Lock, Event,
Condition, Barrier, Semaphore, etc be welcome (for threading,
multiprocess, async, etc)?

Inside the code base, such an attribute would let me do things like:


mycondition.wait()
print(f'Met condition {mycondition.name}')

or

print(f'Waiting on barrier {mybarrier.name}')
mybarrier.wait()

And similar.

Simplifying deep introspection into which sync primitives are which
feels like it would be a benefit as the async world grows within
Python.

Thoughts?

Pat
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/FRXWXCAY3D6TLQZSYMDXPZCDIDHFOUOI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to