I am still stuck with this, and it will be such an awesome example
when it works.

Right now the tkapp.py app works as advertised but hangs on exit. When
you click the Quit button the window closes but the program never
terminates. If you hit CTRL-C the code is invariably parked in that
lock.acquire(block, timeout) call in threading.py.

Meanwhile I wrote tkapp2.py implementing the three approaches for the
expensive processing function (sequential, nested callback and
coroutine), with a button for each. This is nice for doing demos. But
this second version has the same problem as the previous one: hangs on
exit.

Best,

Luciano


On Tue, Jan 20, 2015 at 7:29 PM, Luciano Ramalho <[email protected]> wrote:
> On Tue, Jan 20, 2015 at 2:38 AM, Guido van Rossum <[email protected]> wrote:
>> Thank you. I have not found the time to work on this further myself, so I'd
>> like to hear how you fare!
>
> Hello, I made the example work: the essential Count Words button works
> as advertised (as long as you have the holmes.txt file available).
>
> After applying Guido's patch from 2014-05-17, I had to add touch only
> three lines to make guievents.GuiEventLoop subclass BaseEventLoop
> (previously it subclassed AbstractEventLoop). See changes in [1]
>
> [1] 
> https://bitbucket.org/ramalho/asyncio_staging/commits/8e7668cbd3e28c41f009e48800c9671e227b80e2
>
> But there is still a bug I don't know how to fix: when I click quit
> the Tk window closes by the program hangs. It's a threading issue (see
> output and traceback at the end of this message).
>
> I am now writing a tkapp2.py demo with three buttons, to show the
> three different ways of counting words: sequentially (blocking), using
> callbacks and coroutines.
>
> I'd appreciate help with the threading issue on shutdown. I did some
> research on the Web but did not find a solution yet.
>
> Best,
>
> Luciano
>
> ##################################### output of running tkapp.py
> $ python3 tkapp.py
> Starting on thread -1601961560
> Loading words on  -1601961560
> 110678 words loaded
> Cleaning on  -1601961560
> 107396 remain after cleaning
> Counting on -1601961560
> 7947 distinct words after counting
> Sorting on thread  -1601961560
> The ten most common words: the, and, i, to, of, a, in, that, it, you
> ^CException ignored in: <module 'threading' from
> '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threading.py'>
> Traceback (most recent call last):
>   File 
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threading.py",
> line 1295, in _shutdown
>     t.join()
>   File 
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threading.py",
> line 1061, in join
>     self._wait_for_tstate_lock()
>   File 
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threading.py",
> line 1077, in _wait_for_tstate_lock
>     elif lock.acquire(block, timeout):
> KeyboardInterrupt



-- 
Luciano Ramalho
Twitter: @ramalhoorg

Professor em: http://python.pro.br
Twitter: @pythonprobr

Reply via email to