Topics

Help for threading in py3

Alberto Buffolino
 

Hi all,
I'm trying to fix the threaded search of ColumnsReview in py3 alpha, but I don't understand the log, that says:
***
ERROR - stderr (15:11:43.190) - Thread-180 (14220):
Exception in thread Thread-180:
Traceback (most recent call last):
File "threading.pyc", line 926, in _bootstrap_inner
File "threading.pyc", line 870, in run
File "C:\Standalone\NVDAPy3\userConfig\addons\columnsReview\globalPlugins\columnsReview\__init__.py", line 426, in launchFinder
while finder.is_alive():
File "threading.pyc", line 1103, in is_alive
File "threading.pyc", line 1062, in _wait_for_tstate_lock
TypeError: 'Event' object is not callable
***
This is relative code (written by Cyrille, Finder is a subclass of threading.Thread):
***
def launchFinder(self, text, reverse, caseSensitive):
global gFinder
if gFinder is not None:
gFinder.stop()
gFinder = Finder(self, text, reverse, caseSensitive)
# Create local ref to finder. Local ref should be used during this whole function execution, while global ref may be deleted or overridden.
finder = gFinder
finder.start()
i = 0
while finder.is_alive():
sleep(0.1)
i += 1
if i == 10:
beep(500, 100)
i = 0
finder.join()
if finder.status == Finder.STATUS_COMPLETE:
if finder.res:
core.callLater(0, self.successSearchAction, finder.res)
else:
wx.CallAfter(gui.messageBox, NVDALocale('text "%s" not found')%text, NVDALocale("Find Error"), wx.OK|wx.ICON_ERROR)
else:
core.callLater(0, beep, 220, 150 )
finder = None
***
Any suggestions?
Thanks.
Alberto

Noelia Ruiz
 

Hi Alberto, this is not an answer to your question, but as you know,
Leonard made changes that make that NVDA shows just the visible
columns in lists:
This made unusable your fixed list class for our eMule add-on. Not
sure if this can affect columnsReview too:

commit dbb1cf1e5e5f3f6b7895a12b037cc16b5f107f37
Author: Leonard de Ruijter <leonardder@...>
Date: Tue Sep 17 09:11:21 2019 +0200

Hide invisible columns in syslistview32 lists (#9873)

Cheers


2019-11-30 15:32 GMT+01:00, Alberto Buffolino <a.buffolino@...>:

Hi all,
I'm trying to fix the threaded search of ColumnsReview in py3 alpha, but
I don't understand the log, that says:
***
ERROR - stderr (15:11:43.190) - Thread-180 (14220):
Exception in thread Thread-180:
Traceback (most recent call last):
File "threading.pyc", line 926, in _bootstrap_inner
File "threading.pyc", line 870, in run
File
"C:\Standalone\NVDAPy3\userConfig\addons\columnsReview\globalPlugins\columnsReview\__init__.py",

line 426, in launchFinder
while finder.is_alive():
File "threading.pyc", line 1103, in is_alive
File "threading.pyc", line 1062, in _wait_for_tstate_lock
TypeError: 'Event' object is not callable
***
This is relative code (written by Cyrille, Finder is a subclass of
threading.Thread):
***
def launchFinder(self, text, reverse, caseSensitive):
global gFinder
if gFinder is not None:
gFinder.stop()
gFinder = Finder(self, text, reverse, caseSensitive)
# Create local ref to finder. Local ref should be used during this
whole function execution, while global ref may be deleted or overridden.
finder = gFinder
finder.start()
i = 0
while finder.is_alive():
sleep(0.1)
i += 1
if i == 10:
beep(500, 100)
i = 0
finder.join()
if finder.status == Finder.STATUS_COMPLETE:
if finder.res:
core.callLater(0, self.successSearchAction, finder.res)
else:
wx.CallAfter(gui.messageBox, NVDALocale('text "%s" not found')%text,
NVDALocale("Find Error"), wx.OK|wx.ICON_ERROR)
else:
core.callLater(0, beep, 220, 150 )
finder = None
***
Any suggestions?
Thanks.
Alberto



Alberto Buffolino
 

Noelia Ruiz, il 30/11/2019 17.31, ha scritto:
Hi Alberto, this is not an answer to your question, but as you know,
Leonard made changes that make that NVDA shows just the visible
columns in lists:
This made unusable your fixed list class for our eMule add-on. Not
sure if this can affect columnsReview too:
Alberto:
Hi Noelia,
yes, I read your mail about it :)
I forgot to hide any column in eMule, just done, and yes, I must consider Leonard commit in my code... I'm studying it in this moment.
Thanks for reminder.
Alberto

James Scholes
 

_stop is now a bound method of threading.Thread in Python 3.x. The code:

self._stop = Event()

... in __init__.py, line 210, overrides the built-in bound method. When you later call finder.join(), on line 416, this in turn calls finder._wait_for_tstate_lock() because timeout is None. If we look at the code for threading.Thread._wait_for_tstate_lock, we see:

elif lock.acquire(block, timeout):
lock.release()
self._stop()

Boom. self._stop should be a callable method, but it's now an event object and the whole thing collapses. Change the self._stop assignment to self._stop_event or something.

Regards,

James Scholes

On 30/11/2019 at 8:32 am, Alberto Buffolino wrote:
Hi all,
I'm trying to fix the threaded search of ColumnsReview in py3 alpha, but I don't understand the log, that says:
***
ERROR - stderr (15:11:43.190) - Thread-180 (14220):
Exception in thread Thread-180:
Traceback (most recent call last):
  File "threading.pyc", line 926, in _bootstrap_inner
  File "threading.pyc", line 870, in run
  File "C:\Standalone\NVDAPy3\userConfig\addons\columnsReview\globalPlugins\columnsReview\__init__.py", line 426, in launchFinder
    while finder.is_alive():
  File "threading.pyc", line 1103, in is_alive
  File "threading.pyc", line 1062, in _wait_for_tstate_lock
TypeError: 'Event' object is not callable
***
This is relative code (written by Cyrille, Finder is a subclass of threading.Thread):
***
    def launchFinder(self, text, reverse, caseSensitive):
        global gFinder
        if gFinder is not None:
            gFinder.stop()
        gFinder = Finder(self, text, reverse, caseSensitive)
        # Create local ref to finder. Local ref should be used during this whole function execution, while global ref may be deleted or overridden.
        finder = gFinder
        finder.start()
        i = 0
        while finder.is_alive():
            sleep(0.1)
            i += 1
            if i == 10:
                beep(500, 100)
                i = 0
        finder.join()
        if finder.status == Finder.STATUS_COMPLETE:
            if finder.res:
                core.callLater(0, self.successSearchAction, finder.res)
            else:
                wx.CallAfter(gui.messageBox, NVDALocale('text "%s" not found')%text, NVDALocale("Find Error"), wx.OK|wx.ICON_ERROR)
        else:
            core.callLater(0, beep, 220, 150 )
        finder = None
***
Any suggestions?
Thanks.
Alberto

Alberto Buffolino
 

James Scholes, il 30/11/2019 18.14, ha scritto:
_stop is now a bound method of threading.Thread in Python 3.x.  The code:
Alberto:
uh, I read it online, without noticing it in Cyrille code... ok, fixed.
Thanks James :)
Alberto