mitogen-hq / mitogen

Distributed self-replicating programs in Python
https://mitogen.networkgenomics.com/
BSD 3-Clause "New" or "Revised" License
2.32k stars 197 forks source link

"meta: reset_connection" fails with "become: true" using 0.2.9 #708

Closed mkowalski closed 3 years ago

mkowalski commented 4 years ago

Hi,

Contrary to the release notes for 0.2.9, meta: reset_connection is still failing when used with become: true using the environment specified below.

Ansible 2.8.10
Mitogen 0.2.9
Python (host and target) 3.5.2
Ubuntu 16.04
Strategy mitogen_linear

The following snippet can be used to reproduce the issue

- name: Force reconnection
  meta: reset_connection
- hosts: all
  roles:
    - testing
  become: yes

With the following error appearing

ERROR! [mux  17655] 07:14:35.440029 E mitogen.service: Pool(c128, size=32, th='mitogen.Pool.c128.25'): while invoking 'reset' of 'ansible_mitogen.services.ContextService'
Traceback (most recent call last):
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/service.py", line 621, in _on_service_call
    return invoker.invoke(method_name, kwargs, msg)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/service.py", line 307, in invoke
    response = self._invoke(method_name, kwargs, msg)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/service.py", line 293, in _invoke
    ret = method(**kwargs)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/ansible_mitogen/services.py", line 186, in reset
    mitogen.core.listen(context, 'disconnect', l.put)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/core.py", line 431, in listen
    _signals(obj, name).append(func)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/core.py", line 421, in _signals
    obj.__dict__
AttributeError: 'NoneType' object has no attribute '__dict__'
ERROR! Unexpected Exception, this is probably a bug: builtins.AttributeError: 'NoneType' object has no attribute '__dict__'
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/service.py", line 621, in _on_service_call
    return invoker.invoke(method_name, kwargs, msg)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/service.py", line 307, in invoke
    response = self._invoke(method_name, kwargs, msg)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/service.py", line 293, in _invoke
    ret = method(**kwargs)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/ansible_mitogen/services.py", line 186, in reset
    mitogen.core.listen(context, 'disconnect', l.put)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/core.py", line 431, in listen
    _signals(obj, name).append(func)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/core.py", line 421, in _signals
    obj.__dict__

ERROR! Unexpected Exception, this is probably a bug: builtins.AttributeError: 'NoneType' object has no attribute '__dict__'
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/service.py", line 621, in _on_service_call
    return invoker.invoke(method_name, kwargs, msg)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/service.py", line 307, in invoke
    response = self._invoke(method_name, kwargs, msg)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/service.py", line 293, in _invoke
    ret = method(**kwargs)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/ansible_mitogen/services.py", line 186, in reset
    mitogen.core.listen(context, 'disconnect', l.put)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/core.py", line 431, in listen
    _signals(obj, name).append(func)
  File "/home/ubuntu/ansible/plugins/mitogen-0.2.9/mitogen/core.py", line 421, in _signals
    obj.__dict__

to see the full traceback, use -vvv

(more extended log - log.txt)

Related-issue: https://github.com/dw/mitogen/issues/633

s1113950 commented 4 years ago

https://github.com/dw/mitogen/issues/655 had a similar traceback to yours; can you try my branch here: https://github.com/dw/mitogen/pull/710 and see if it works for you? The part that triggers the bug is when a reset is called but there's no call stack context to disconnect from.

mkowalski commented 3 years ago

The branch has been merged and it's been quite some time since this bug has been opened. I'll close it and reopen if it by any chance happens again