Chris wrote:
> This is thread-safe:
>
> from threading import Lock
> 
> lock = Lock()
> counter = 0
> def get_next():
>    with lock:
>        global counter
>        counter += 1
>        my_counter = counter

This is a great workaround. I can try to improve this. But first of all should 
we depend on the user to do this locking? I don't think so. So is it possible 
to implement this in the background without affecting current performance?
_______________________________________________
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/MMC4MFCMWH2VZXKKAKVC2NFQJENOMI74/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to