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

PyPy3.7 compatability #1785

Closed
olliemath opened this issue Apr 16, 2021 · 4 comments
Closed

PyPy3.7 compatability #1785

olliemath opened this issue Apr 16, 2021 · 4 comments

Comments

@olliemath
Copy link

olliemath commented Apr 16, 2021

  • gevent version: 21.1.2
  • Python version: PyPy 3.7-7.3.4
  • Operating System: Linux

Description:

Currently I'm trying to get the following snippet to work with the latest pypy (3.7-7.3.4), however it hangs forever

import gevent
from gevent import socket

def get():
   socket.gethostbyname('www.python.org')

g = gevent.spawn(get)
g.join()

Right now this is as far as I've been able to dig, so unsure whether this is an issue with pypy or gevent (or just a general incompatibility) the snippet works in cpython, pypy3.6, and with equivalent eventlet code. A keyboard interupt gets us

^CTraceback (most recent call last):
  File "/home/oliver/gevent/venv/site-packages/gevent/libev/corecffi.py", line 58, in python_check_callback
    pass
KeyboardInterrupt
2021-04-16T23:28:51Z
Traceback (most recent call last):
  File "gsockets.py", line 11, in <module>
    g.join()
  File "/home/oliver/gevent/venv/site-packages/gevent/greenlet.py", line 846, in join
    result = get_my_hub(self).switch() # pylint:disable=undefined-variable
  File "/home/oliver/gevent/venv/site-packages/gevent/_greenlet_primitives.py", line 65, in switch
    return _greenlet_switch(self) # pylint:disable=undefined-variable
  File "/usr/lib/pypy3/lib_pypy/greenlet.py", line 63, in switch
    return self.__switch('switch', (args, kwds))
  File "/usr/lib/pypy3/lib_pypy/greenlet.py", line 104, in __switch
    args, kwds = unbound_method(current, *baseargs, to=target)
  File "/home/oliver/gevent/venv/site-packages/gevent/libev/corecffi.py", line 58, in python_check_callback
    pass
KeyboardInterrupt

Here is a minimal dockerfile if you'd like to reproduce:

FROM pypy:3.7-7.3.4
RUN pip3 install gevent==21.1.2
RUN printf "import gevent\nfrom gevent import socket\ndef get():\n  socket.gethostbyname('www.python.org')\ng = gevent.spawn(get)\ng.join()" > app.py
RUN pypy3 app.py  # <- hangs forever

Other things I've tried

As above, but replaced with a sleep works fine:

import gevent
from gevent import sleep

def snooze():
    sleep(1)

g = gevent.spawn(snooze)
g.join()  # <- returns fine

As above, but with monkey-patched stdlib does not work:

from gevent import monkey
monkey.patch_all()

import socket
import threading

def get():
    socket.gethostbyname('www.python.org')

t = threading.Thread(target=get)
t.start()
t.join()  # Hangs forever
@jamadden
Copy link
Member

Thank you for the report. I noticed this on another project of mine today, I just haven't had a chance to dig into it yet.

jamadden added a commit to zodb/relstorage that referenced this issue Apr 19, 2021
To fix the hangs after github silently upgraded to 7.3.4. It seems 7.3.4 broke gevent. See gevent/gevent#1785
@jamadden
Copy link
Member

This was identified as a bug in PyPy and should be fixed in the next release.

@mattip
Copy link

mattip commented Jun 21, 2021

For reference, the PyPy bugfix release 7.3.5 (released 5.23.21, should be on conda soon) should have fixed this.

@olliemath
Copy link
Author

The 7.3.5 release does fix this, thanks!

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

3 participants