diff --git a/docs/changelog.rst b/docs/changelog.rst index af756f37..6d35b7b2 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -27,6 +27,7 @@ In progress (unreleased) * :gh:issue:`1354` docs: Document Ansible 13 (ansible-core 2.20) support * :gh:issue:`1354` :mod:`mitogen`: Clarify error message when a module request would be refused by allow or deny listing +* :gh:issue:`1348` :mod:`mitogen`: Fix hanging process with 100% CPU usage v0.3.35 (2025-12-01) diff --git a/mitogen/parent.py b/mitogen/parent.py index 9da5d58a..97681653 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -1436,11 +1436,16 @@ class Connection(object): os.environ['ARGV0']=sys.executable os.execl(sys.executable,sys.executable+'(mitogen:%s)'%sys.argv[2]) os.write(1,'MITO000\n'.encode()) + # Size of the compressed core source to be read + n=int(sys.argv[3]) # Read `len(compressed preamble)` bytes sent by our Mitogen parent. # `select()` handles non-blocking stdin (e.g. sudo + log_output). # `C` accumulates compressed bytes. C=''.encode() - while int(sys.argv[3])-len(C)and select.select([0],[],[]):C+=os.read(0,int(sys.argv[3])-len(C)) + # data chunk + V='V' + # Stop looping if no more data is needed or EOF is detected (empty bytes). + while n-len(C) and V:select.select([0],[],[]);V=os.read(0,n-len(C));C+=V # Raises `zlib.error` if compressed preamble is truncated or invalid C=zlib.decompress(C) f=os.fdopen(W,'wb',0)