Skip to content

Fixup of: 'NVDA logging: add originating thread to log entry'#10267

Merged
michaelDCurran merged 2 commits into
nvaccess:masterfrom
BabbageCom:loggingFix
Sep 23, 2019
Merged

Fixup of: 'NVDA logging: add originating thread to log entry'#10267
michaelDCurran merged 2 commits into
nvaccess:masterfrom
BabbageCom:loggingFix

Conversation

@LeonarddeR

Copy link
Copy Markdown
Collaborator

Link to issue number:

Fixes #10266

Summary of the issue:

Pr #10259 introduces two issues;

  1. In gui.ExecAndPump, we were setting a name on a thread that was not yet initialized.
  2. For functions defined on the python console, the module property is empty.

Description of how this pull request fixes the issue:

  1. In gui.ExecAndPump, provide the name as an argument to the super call of init, rather than using the setter for the name property.
  2. Just use the repr of the function for gui.ExecAndPump and watchdog.CancellableCallThread. I know it's not the most readable presentation, but it is at least reliable.

Testing performed:

Tested that logs initiated from a function running in a gui.ExecAndPump log the proper thread identifier.

Known issues with pull request:

None

Change log entry:

None

@AppVeyorBot

Copy link
Copy Markdown

PR introduces Flake8 errors 😲

See test results for Failed build of commit aaea543c33

@Brian1Gaff

Brian1Gaff commented Sep 23, 2019 via email

Copy link
Copy Markdown

@JulienCochuyt

Copy link
Copy Markdown
Contributor

@LeonarddeR sorry for the collision, I did not notice you were already working on this when I filled PR #10269.

I do not think we need to fully revert the naming of gui.ExecuteAndPump, naming it in the initializer super call proves to do the trick.

As for your proposed change in watchdog.py, isn't CancellableCallThread.execute called by Thread.start? This would mean the thread is already correctly initialized, unless we cannot set the name once done… ?

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

The reason why I removed the logic that gets a name from the function is an unrelated issue. It's because functions defined in the python console have a module attribute of None. Trying to concatenate None with str results in an error.

The problem is here that we have to be absolutely sure about edge cases. Alternatively, we could use a try/except block to calculate a human readable name, but there's also something to say for consistency.

@JulienCochuyt

JulienCochuyt commented Sep 23, 2019

Copy link
Copy Markdown
Contributor

The reason why I removed the logic that gets a name from the function is an unrelated issue. It's because functions defined in the python console have a module attribute of None. Trying to concatenate None with str results in an error.

I also pushed a fix for this in PR #10269.

The problem is here that we have to be absolutely sure about edge cases. Alternatively, we could use a try/except block to calculate a human readable name, but there's also something to say for consistency.

A try/except block here would IMHO be overkill once we've nailed down the few different situations, but it of course couldn't hurt.
As for consistency, _FuncPtr are by nature different, and I do not feel much inconsistance in treating them differently, but this probably is just a matter of taste, no big deal.

EDIT: My second commit doesn't show up in PR #10269 as you closed it. Nevermind.

@LeonarddeR

LeonarddeR commented Sep 23, 2019 via email

Copy link
Copy Markdown
Collaborator Author

@JulienCochuyt

Copy link
Copy Markdown
Contributor

_FuncPtr isn't the only exception, functools.Partial also doesn't have a qualname

Good to know. Thanks for the precision.

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

I'm afraid I don't see the fix in #10269, probably because I closed it. Still, I think I want to be 100% sure that this works. Note that it is mainly for logging, it doesn't have to look super elegant.

@JulienCochuyt

Copy link
Copy Markdown
Contributor

I'm afraid I don't see the fix in #10269, probably because I closed it. Still, I think I want to be 100% sure that this works. Note that it is mainly for logging, it doesn't have to look super elegant.

No problem.
If you want to have a look, it's accessolutions/nvda@0167e5956d2 in branch accessolutions/nvda/i10266-threadLogFixup
I'm quite sure you have a much better view than I do about which functions get usually passed as the target of these two threads.
I can only notice that repr of a bound method is theoretically much more lengthy than this constructed fully qualified name, includes the id of the bound object and misses the module path.
Anyhow, PR #10259 already provides us with much more useful info than we got before it.
I'm already impacting my personal LogViewer quickNav tool to jump from/to entries of the same thread...

@michaelDCurran michaelDCurran merged commit bde76ec into nvaccess:master Sep 23, 2019
@nvaccessAuto nvaccessAuto added this to the 2019.3 milestone Sep 23, 2019
@LeonarddeR LeonarddeR deleted the loggingFix branch September 24, 2019 05:10
@LeonarddeR LeonarddeR added the BabbageWork Pull requests filed on behalf of Babbage B.V. label Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BabbageWork Pull requests filed on behalf of Babbage B.V.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Current alpha nap cannot create portable version

6 participants