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

tests.patcher_test.test_fork_after_monkey_patch fails on py3.9 #646

Open
mgorny opened this issue Sep 24, 2020 · 6 comments
Open

tests.patcher_test.test_fork_after_monkey_patch fails on py3.9 #646

mgorny opened this issue Sep 24, 2020 · 6 comments

Comments

@mgorny
Copy link
Contributor

mgorny commented Sep 24, 2020

This looks like a regression due to a new test.

$ python3.9 --version
Python 3.9.0rc2
tests.patcher_test.test_fork_after_monkey_patch ... Program /tmp/portage/dev-python/eventlet-0.28.0/work/eventlet-0.28.0/tests/isolated/patcher_fork_after_monkey_patch.py output:
---
Exception ignored in: <function _after_fork at 0x7f2c51f7d430>
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 1492, in _after_fork
    thread._reset_internal_locks(False)
  File "/usr/lib/python3.9/threading.py", line 827, in _reset_internal_locks
    self._started._at_fork_reinit()
  File "/usr/lib/python3.9/threading.py", line 527, in _at_fork_reinit
    self._cond._at_fork_reinit()
  File "/usr/lib/python3.9/threading.py", line 253, in _at_fork_reinit
    self._lock._at_fork_reinit()
AttributeError: 'Semaphore' object has no attribute '_at_fork_reinit'
Exception ignored in: <function _after_fork at 0x7f2c51f4a670>
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 1492, in _after_fork
    thread._reset_internal_locks(False)
  File "/usr/lib/python3.9/threading.py", line 827, in _reset_internal_locks
    self._started._at_fork_reinit()
  File "/usr/lib/python3.9/threading.py", line 527, in _at_fork_reinit
    self._cond._at_fork_reinit()
  File "/usr/lib/python3.9/threading.py", line 253, in _at_fork_reinit
    self._lock._at_fork_reinit()
AttributeError: 'Semaphore' object has no attribute '_at_fork_reinit'
Exception ignored in: <function _after_fork at 0x7f2c50813550>
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 1486, in _after_fork
    thread._reset_internal_locks(True)
  File "/usr/lib/python3.9/threading.py", line 827, in _reset_internal_locks
    self._started._at_fork_reinit()
  File "/usr/lib/python3.9/threading.py", line 527, in _at_fork_reinit
    self._cond._at_fork_reinit()
  File "/usr/lib/python3.9/threading.py", line 253, in _at_fork_reinit
    self._lock._at_fork_reinit()
AttributeError: 'Semaphore' object has no attribute '_at_fork_reinit'
Traceback (most recent call last):
  File "/tmp/portage/dev-python/eventlet-0.28.0/work/eventlet-0.28.0/tests/isolated/patcher_fork_after_monkey_patch.py", line 42, in <module>
    check(1, threading, 'child post-fork patched')
  File "/tmp/portage/dev-python/eventlet-0.28.0/work/eventlet-0.28.0/tests/isolated/patcher_fork_after_monkey_patch.py", line 7, in check
    assert len(mod._active) == n, 'Expected {} {} threads, got {}'.format(n, tag, mod._active)
AssertionError: Expected 1 child post-fork patched threads, got {139828348036928: <_MainThread(MainThread, stopped 139828348036928)>, 139828306105792: <Thread(patched, started 139828306105792)>, 139828330865232: <_MainThread(MainThread, started 139828330865232)>}
pass

---
FAIL
@ziddey
Copy link

ziddey commented Oct 17, 2020

Seeing this on starting gunicorn with eventlet as well. Doesn't seem to have broken anything as far as I can tell.

python 3.9.0, eventlet 0.28.0

@temoto
Copy link
Member

temoto commented Oct 17, 2020

@tipabu ideas?

@temoto
Copy link
Member

temoto commented Oct 17, 2020

On surface it seems eventlet Semaphore must implement new API _at_fork_reinit, relevant to general 3.9 support besides #611

@ziddey
Copy link

ziddey commented Oct 19, 2020

Took a cursory look as well. Relevant lines:

_thread.Lock._at_fork_reinit() implementation: https://github.com/python/cpython/blob/3.9/Modules/_threadmodule.c#L210

should be fine to call self.__init__(1)? Seems to be working here.

Note threading.Semaphore doesn't have an _at_fork_reinit method

tipabu added a commit to tipabu/eventlet that referenced this issue Nov 3, 2020
CPython expects to be able to call such a method on RLocks, Conditions,
and Events in threading; since we may monkey-patch threading to use
Semaphores as locks, they need the method, too.

Addresses eventlet#646
jstasiak pushed a commit that referenced this issue Nov 3, 2020
CPython expects to be able to call such a method on RLocks, Conditions,
and Events in threading; since we may monkey-patch threading to use
Semaphores as locks, they need the method, too.

Addresses #646
@aescobar-icc
Copy link

downgrade to python 3.8 works for me

@4383
Copy link
Member

4383 commented Mar 13, 2024

Hello,

I think this bug is now fixed, please can you check with the latest eventlet versions and confirm if you still reproduce the issue. I do not observe similar issue on my side.

Thanks in advance.

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

No branches or pull requests

5 participants