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

Already on GitHub? Sign in to your account

_reuse() #12

Open
robvoi opened this Issue Dec 20, 2013 · 1 comment

Comments

Projects
None yet
2 participants

robvoi commented Dec 20, 2013

I tried the pypy hack for gevent. My pypy prgram (flask with sse) starts. But when I try to connect I get the following error:

Traceback (most recent call last):
File "build/bdist.linux-armv6l/egg/gevent/greenlet.py", line 328, in run
result = self._run(_self.args, *_self.kwargs)
File "build/bdist.linux-armv6l/egg/gevent/pywsgi.py", line 653, in handle
handler = self.handler_class(socket, address, self)
File "build/bdist.linux-armv6l/egg/gevent/pywsgi.py", line 175, in init
self.rfile = socket.makefile('rb', -1)
File "build/bdist.linux-armv6l/egg/gevent/socket.py", line 379, in makefile
return _fileobject(type(self)(_sock=self), mode, bufsize)
File "/usr/lib/pypy-upstream/lib-python/2.7/socket.py", line 300, in init
sock._reuse()
AttributeError: 'socket' object has no attribute '_reuse'
<Greenlet at 0x4737a10L: <bound method WSGIServer.handle of <WSGIServer at 0x465d630L fileno=6 address=0.0.0.0:9999>>(<socket at 0x4737a30L fileno=8 sock=192.168.1.199:, ('84.63.102.205', 52661))> failed with AttributeError

I found a comment which may help here: https://mail.python.org/pipermail/pypy-commit/2013-August/076563.html

  •        # PyPy note about refcounting: implemented with _reuse()/_drop()
    
  •        # on the class '_socket.socket'.  Python 3 did it differently
    
  •        # with a reference counter on this class 'socket._socketobject'
    
  •        # instead, but it is a less compatible change.
    
  •        # Note that a few libraries (like eventlet) poke at the
    
  •        # private implementation of socket.py, passing custom
    
  •        # objects to _socketobject().  These libraries need the
    
  •        # following fix for use on PyPy: the custom objects need
    
  •        # methods _reuse() and _drop() that maintains an explicit
    
  •        # reference counter, starting at 0.  When it drops back to
    
  •        # zero, close() must be called.
    

And a comment from the pypy-dev mailing list with an interesting link:

"No, this isn't a bug in PyPy. If gevent wants to use the internal details of
the socket module in way's that aren't defined, they need to pass somethign
which matches the required interface.

it's worth noting that eventlet had the same issue, and it was fixed here (thanks to... Alex :)):

eventlet/eventlet@2633322
"

Contributor

schmir commented Dec 20, 2013

see #11. pypycore needs a maintainer, I wouldn't use it for serious work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment