• Kirill Smelkov's avatar
    gpython: Workaround PyPy2 vs Gevent patch_thread crash · 704d99f0
    Kirill Smelkov authored
    	pypy-gevent runtests: commands[0] | gpython -m pytest gpython/ golang/
    	Traceback (most recent call last):
    	  File "/home/kirr/src/tools/go/pygolang/.tox/pypy-gevent/bin/gpython", line 10, in <module>
    	    sys.exit(main())
    	  File "/home/kirr/src/tools/go/pygolang/.tox/pypy-gevent/site-packages/gpython/__init__.py", line 153, in main
    	    _ = monkey.patch_all()      # XXX sys=True ?
    	  File "/home/kirr/src/tools/go/pygolang/.tox/pypy-gevent/site-packages/gevent/monkey.py", line 976, in patch_all
    	    patch_thread(Event=Event, _warnings=_warnings)
    	  File "/home/kirr/src/tools/go/pygolang/.tox/pypy-gevent/site-packages/gevent/monkey.py", line 178, in ignores
    	    return func(*args, **kwargs)
    	  File "/home/kirr/src/tools/go/pygolang/.tox/pypy-gevent/site-packages/gevent/monkey.py", line 588, in patch_thread
    	    _patch_existing_locks(threading_mod)
    	  File "/home/kirr/src/tools/go/pygolang/.tox/pypy-gevent/site-packages/gevent/monkey.py", line 492, in _patch_existing_locks
    	    if o._RLock__owner is not None:
    	AttributeError: 'thread.RLock' object has no attribute '_RLock__owner'
    
    It will be fixed on next Gevent release, however until then the crash is there
    and we have to workaround: we can skip patching existing locks as it will be
    the same behaviour of next Gevent release, since its just not possible to patch
    locks created via instantiated C-level classes:
    
    https://github.com/gevent/gevent/commit/d0e04658
    
    We are doing monkey-patching very early, so it should be safe.
    704d99f0
__init__.py 6.58 KB