Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress unreachable symbol warnings; don't write cached tables #250

Merged
merged 2 commits into from
Mar 3, 2023

Conversation

mikebveil
Copy link
Contributor

@mikebveil mikebveil commented Apr 29, 2021

Address two outstanding issues that are especially a problem when using flanker in a frozen application (i.e. using pyinstaller).

#231 Disable warnings on first run

When addresslib is first imported, the yacc parser gets run and logs a bunch of warnings about missing symbols. This pollutes the stdout (or maybe stderr) of the application using it. And when freezing with pyInstaller, the directory with cached tables is removed between runs, so this happens on every run. I have no idea if these warnings are themselves a bug, but they shouldn't be exposed like this and setting check_recursion=False suppresses them.

#208 Don't generate cached parser tables

When running in a read-only filesystem, yacc will fail to write out the cached parser tables. This affects, for example, AWS Lambda and pyInstaller builds. It's not fatal, but it does generate an error in the application output each time.

There is a cost to write_tables=False, since we will have to re-parse on the next startup. But it's worth noting that the next version of the yacc module will do away with caching entirely, and the author considers it of negligible performance benefit:

PLY no longer writes cached table files. Honestly, the use of the cached files made more sense when I was developing PLY on my 200Mhz PC in 2001. It's not as much as an issue now. For small to medium sized grammars, PLY should be almost instantaneous. If you're working with a large grammar, you can arrange to pickle the associated grammar instance yourself if need be.

Testing

Have verified no regressions in nosetests.

…e that may not be allowed in some runtime environments.
@mailgun-ci
Copy link

Can one of the admins verify this patch?

@Torxed
Copy link

Torxed commented Mar 3, 2023

If this PR isn't what the authors would want,
at least do:

log = logging.getLogger(__name__)
+ log.level = logging.ERROR

in

log = logging.getLogger(__name__)

We're 2 years in to this PR, and the WARNING: Symbol '...' is unreachable is still at large.

Copy link
Contributor

@thrawn01 thrawn01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to age and by popular community request I will merge this. However I am not a python maintainer and have not vetted this PR.

@thrawn01 thrawn01 merged commit 0c774c0 into mailgun:master Mar 3, 2023
@Torxed
Copy link

Torxed commented Mar 3, 2023

Due to age and by popular community request I will merge this. However I am not a python maintainer and have not vetted this PR.

Thank you! Our logs and storage are forever in your debt! ^^

@danielkauffman
Copy link

Thank you! This should resolve https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1033714

@danielkauffman
Copy link

Is there a release schedule for flanker? Would be great to get this package into Debian Bookworm, which is currently approaching release.

@danielkauffman
Copy link

Is there a release schedule for flanker? Would be great to see this patch released and in Debian.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants