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

Syntax error when Gunicorn with Python 3.4 #515

Closed
Kmaschta opened this Issue Nov 28, 2014 · 6 comments

Comments

Projects
None yet
7 participants
@Kmaschta

Kmaschta commented Nov 28, 2014

Hi there !

I have this traceback when I run gevent with gunicorn in Python 3.4.2

gunicorn ${DJANGO_WSGI_MODULE}:application --name $NAME --workers 4 --timeout 120 --user=root --group=root --log-level=debug --bind=unix:/var/run/gunicorn.sock --worker-class gevent

Traceback (most recent call last):
  File "./manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
Traceback (most recent call last):
  File "./manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

Error: class uri 'gevent' invalid or not found: 

[Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/gunicorn/util.py", line 139, in load_class
    mod = import_module('.'.join(components))
  File "/usr/local/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/usr/local/lib/python3.4/site-packages/gunicorn/workers/ggevent.py", line 20, in <module>
    import gevent
  File "/usr/local/lib/python3.4/site-packages/gevent/__init__.py", line 36, in <module>
    from gevent.hub import get_hub, iwait, wait
  File "/usr/local/lib/python3.4/site-packages/gevent/hub.py", line 282
    except Exception, ex:
                    ^
SyntaxError: invalid syntax
]
Traceback (most recent call last):
  File "./manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
Traceback (most recent call last):
  File "./manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

Error: class uri 'gevent' invalid or not found: 

[Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/gunicorn/util.py", line 139, in load_class
    mod = import_module('.'.join(components))
  File "/usr/local/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/usr/local/lib/python3.4/site-packages/gunicorn/workers/ggevent.py", line 20, in <module>
    import gevent
  File "/usr/local/lib/python3.4/site-packages/gevent/__init__.py", line 36, in <module>
    from gevent.hub import get_hub, iwait, wait
  File "/usr/local/lib/python3.4/site-packages/gevent/hub.py", line 282
    except Exception, ex:
                ^
SyntaxError: invalid syntax
]

Traceback (most recent call last):
  File "./manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
Traceback (most recent call last):
  File "./manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

Error: class uri 'gevent' invalid or not found: 

[Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/gunicorn/util.py", line 139, in load_class
    mod = import_module('.'.join(components))
  File "/usr/local/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/usr/local/lib/python3.4/site-packages/gunicorn/workers/ggevent.py", line 20, in <module>
    import gevent
  File "/usr/local/lib/python3.4/site-packages/gevent/__init__.py", line 36, in <module>
    from gevent.hub import get_hub, iwait, wait
  File "/usr/local/lib/python3.4/site-packages/gevent/hub.py", line 282
    except Exception, ex:
                ^
SyntaxError: invalid syntax
]

Traceback (most recent call last):
  File "./manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
Traceback (most recent call last):
  File "./manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

Error: class uri 'gevent' invalid or not found: 

[Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/gunicorn/util.py", line 139, in load_class
    mod = import_module('.'.join(components))
  File "/usr/local/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/usr/local/lib/python3.4/site-packages/gunicorn/workers/ggevent.py", line 20, in <module>
    import gevent
  File "/usr/local/lib/python3.4/site-packages/gevent/__init__.py", line 36, in <module>
    from gevent.hub import get_hub, iwait, wait
  File "/usr/local/lib/python3.4/site-packages/gevent/hub.py", line 282
    except Exception, ex:
                    ^
SyntaxError: invalid syntax
@fantix

This comment has been minimized.

Show comment
Hide comment
@fantix

fantix Nov 30, 2014

Contributor

c093b89 fixed this

Contributor

fantix commented Nov 30, 2014

c093b89 fixed this

@Ivoz

This comment has been minimized.

Show comment
Hide comment
@Ivoz

Ivoz Dec 6, 2014

Contributor

No gevent stable release works on python 3 yet. Support for it is in development.

Contributor

Ivoz commented Dec 6, 2014

No gevent stable release works on python 3 yet. Support for it is in development.

@Zearin Zearin referenced this issue Feb 4, 2015

Closed

Add “Python3” label to these issues #538

4 of 4 tasks complete

@denik denik added the python3 label May 18, 2015

@avalanchy

This comment has been minimized.

Show comment
Hide comment
@avalanchy

avalanchy Jun 8, 2015

f6489da again removed to achieve python 2.5 support

avalanchy commented Jun 8, 2015

f6489da again removed to achieve python 2.5 support

@smurfix

This comment has been minimized.

Show comment
Hide comment
@smurfix

smurfix Jun 17, 2015

Contributor

Quite frankly, I fail to understand why supporting 2.5 seems to be more important that supporting 3.x.

Contributor

smurfix commented Jun 17, 2015

Quite frankly, I fail to understand why supporting 2.5 seems to be more important that supporting 3.x.

@jamadden

This comment has been minimized.

Show comment
Hide comment
@jamadden

jamadden Jun 17, 2015

Member

Please note that the change in question was only in the 1.0.2 released branch, and the 1.0.x series supports Python 2.5-2.7. It has no impact on the Python 3 support added in master. You can see those builds all passing on Travis.

Member

jamadden commented Jun 17, 2015

Please note that the change in question was only in the 1.0.2 released branch, and the 1.0.x series supports Python 2.5-2.7. It has no impact on the Python 3 support added in master. You can see those builds all passing on Travis.

@jamadden

This comment has been minimized.

Show comment
Hide comment
@jamadden

jamadden Jun 20, 2015

Member

Closing this issue because it was a case of trying to use gevent 1.0.1 under Python 3, which is not supported. At this time, only unreleased master can be used under Python 3.

Member

jamadden commented Jun 20, 2015

Closing this issue because it was a case of trying to use gevent 1.0.1 under Python 3, which is not supported. At this time, only unreleased master can be used under Python 3.

@jamadden jamadden closed this Jun 20, 2015

@roidelapluie roidelapluie referenced this issue Jan 22, 2016

Closed

Activer le support des websockets en prod #102

4 of 6 tasks complete

hashbrowncipher pushed a commit to hashbrowncipher/gevent that referenced this issue Oct 20, 2018

Fix substitution problems introduced in 2.8 (gevent#599)
* gevent#595 fix by updating implementation of gevent#515

The way gevent#515 was implemented did not play nicely with env var substitution. This might render the former additions completely or partially obsolete but I did not check this yet. First let's fix that bug.

* fix flakes

(cherry picked from commit e902f04)

* gevent#595 fix by updating implementation of gevent#515

The way gevent#515 was implemented did not play nicely with env var substitution. This might render the former additions completely or partially obsolete but I did not check this yet. First let's fix that bug.

Instead of crashing early on testenv creation if the substitution the missing substitution keys are added to a list attached to TestenvConfig. This way it is not necessary anymore to provide everything needed to resolve all testenvs but instead only what is needed to resolve all testenvs that are part of this restrun.

Implementation notes:

The first implementation used a module level mapping from envname to missing substitutions, which was ugly. Instead the information is bubbled up as an exception where it can be handled the way it is needed in the contexts where the information can be either translated into a crashing error or attached to the object which should carry the information (in this case TestenvConfig).

Atm a missing substitution in a testenv is not being left empty but filled with a special value 'TOX_MISSING_SUBSTITUTION', this is not exactly necessary, but I don't feel comfortable enough yet to leave it empty, this can help with debugging potential problems that might arise from this change.

* gevent#595 missed a bit

Crash only if actually trying to run a testenv with missing substitutions

* fix error on execution

Instead of crashing the whole thing again - only later, do it the right way by setting venv.status with the error to be reported later.

* gevent#595 tests and last touches

* catch MissingSubstition from all method calls for consistency
* set status and stop execution in setupvenv if substutions are missing to prevent errors occuring there with missing substitutions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment