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

parsetab module is not always generated property by ply #168

Closed
rmihael opened this issue Jul 14, 2017 · 9 comments
Closed

parsetab module is not always generated property by ply #168

rmihael opened this issue Jul 14, 2017 · 9 comments

Comments

@rmihael
Copy link

rmihael commented Jul 14, 2017

It seems that there is some race condition with parsetab module that PLY generates. On flanker-0.7.2 we are getting the error that reproduces randomly in identical environments:

    from flanker.addresslib import address
runtime/lib/python2.7/site-packages/flanker/addresslib/address.py:46: in <module>
    from flanker.addresslib.parser import (Mailbox, Url, mailbox_parser,
runtime/lib/python2.7/site-packages/flanker/addresslib/parser.py:162: in <module>
    start='mailbox', errorlog=log)
runtime/lib/python2.7/site-packages/ply/yacc.py:3287: in yacc
    read_signature = lr.read_table(tabmodule)
runtime/lib/python2.7/site-packages/ply/yacc.py:1985: in read_table
    if parsetab._tabversion != __tabversion__:
E   AttributeError: 'module' object has no attribute '_tabversion'

parsetab.py file is correct and has all expected variables. However parsetab.pyc seems to be an empty module. After removing pyc file from flanker.addresslib import address works correctly.

May be it is worth to add a generated parsetab.py into the package distribution?

@rmihael rmihael changed the title parsetab module is not always ganerated property by ply parsetab module is not always generated property by ply Jul 14, 2017
@jlev
Copy link

jlev commented Sep 11, 2017

I also had this problem intermittently when deploying to Heroku. I solved it by adding a pre-start script to my Procfile that imports flanker so the parsetab is generated, and then runs my production app. Seems to work, although it's a bit of a hack.

@rmihael
Copy link
Author

rmihael commented Sep 13, 2017

We tried something similar, but with no success. It seems that the issue is somehow connected to gevent. We haven't experienced it with non-gevent processes.

@jlev
Copy link

jlev commented Sep 22, 2017

Still having this problem, even with the pre-start script, and without using gevent.

Other options:

I've followed the first approach with spacedogXYZ@54d5008 and it appears to work for my use case, although I haven't benchmarked it heavily.

@Viech
Copy link

Viech commented Oct 25, 2017

According to this answer this may be a regression from PLY 3.4 to 3.6. (I'm having the same problem as described in that thread with the SWIG-generated Python 2 bindings for GLPK; I have PLY 3.10 installed.)

@horkhe
Copy link
Member

horkhe commented Apr 9, 2018

As of #188 we ship parsetab along with Flanker.

@horkhe horkhe closed this as completed Apr 9, 2018
@pudo
Copy link

pudo commented May 22, 2018

We're still seeing this error with 0.9.0, but for a different module -- what could be the fix?

AttributeError: module 'flanker.addresslib._parser.url_parsetab' has no attribute '_tabversion'

@horkhe
Copy link
Member

horkhe commented May 23, 2018

Try pinning ply to v3.10, it is the version used to generate parsetab files shipped with Flanker. If the ply version installed is other than v3.10, then it regenerates the parsetab files. That obviously happens in your case and the regenerated files are missing _tabversion for some reason. Probably due to regression in ply that @Viech talked about.

pudo added a commit to alephdata/aleph that referenced this issue May 23, 2018
@pudo
Copy link

pudo commented May 23, 2018

thanks, that appears to fix it. appreciate the help.

@horkhe
Copy link
Member

horkhe commented May 23, 2018

👍 glad to help

jfly added a commit to jfly/ply that referenced this issue Sep 21, 2018
The previous implementation had issues with multiple python processes
simultaneously invoking `.yacc(...)` with the same arugments. One of them
could be midway through generating a .py file that the other process
would attempt to import and then crash with a `SyntaxError`. This diff
avoids that problem by instead writing to a tempfile and then atomically
renaming it. This means processes starting up at the same time will both
do the same work, but that's a lot better than having one of them crash!

`flanker` had this issue reported to them in
mailgun/flanker#168 and they attempted to work
around this by committing the parsetab files that ply generates
(mailgun/flanker#188), but this doesn't help if
the user is running a different version of ply than the version that
flanker generated their parsetab files with (because ply will go ahead
and regenerate those files).
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

No branches or pull requests

5 participants