Barney Stratford added the comment:

You're absolutely right. I had elided the details of the locking from my 
original use case, but now I look at it again, I see that even what I did have 
wasn't enough.

I've made a new patch that takes a lock properly. A non-blocking acquisition of 
the lock will serve the same purpose as looking to see if there is a line being 
read, and will also prevent the interpreter from starting to read a new line 
while the text is being printed.

My use case now looks like this.

reading_lock = threading.Lock ()
readline.set_lock (reading_lock)

def describe (indicator):
        if reading_lock.acquire (False):
                print (indicator.description)
                reading_lock.release ()
        else:
                print ()
                print (indicator.description)
                readline.forced_update_display ()

----------
Added file: http://bugs.python.org/file40104/patch.txt

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24727>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to