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

Get mitogen.fakessh module working again #683

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ v0.3.3.dev0
* :gh:issue:`920` Support Ansible :ans:conn:`~podman` connection plugin
* :gh:issue:`836` :func:`mitogen.utils.with_router` decorator preserves the docstring in addition to the name.
* :gh:issue:`936` :ans:mod:`fetch` no longer emits `[DEPRECATION WARNING]: The '_remote_checksum()' method is deprecated.`
* :gh:pull:`683`: Previously broken :mod:`mitogen.fakessh` functionality is restored


v0.3.2 (2022-01-12)
Expand Down
12 changes: 7 additions & 5 deletions mitogen/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@ def set_protocol(self, protocol):
self.protocol = protocol
self.protocol.stream = self

def accept(self, rfp, wfp):
def accept(self, rfp, wfp, cloexec=True):
"""
Attach a pair of file objects to :attr:`receive_side` and
:attr:`transmit_side`, after wrapping them in :class:`Side` instances.
Expand All @@ -1715,8 +1715,8 @@ def accept(self, rfp, wfp):
:param file wfp:
The file object to transmit to.
"""
self.receive_side = Side(self, rfp)
self.transmit_side = Side(self, wfp)
self.receive_side = Side(self, rfp, cloexec=cloexec)
self.transmit_side = Side(self, wfp, cloexec=cloexec)

def __repr__(self):
return "<Stream %s #%04x>" % (self.name, id(self) & 0xffff,)
Expand Down Expand Up @@ -3804,7 +3804,7 @@ def __init__(self, config):
self.config = config

def _on_broker_exit(self):
if not self.config['profiling']:
if not self.config['profiling'] and not hasattr(mitogen, "exit_status"):
os.kill(os.getpid(), signal.SIGTERM)
Comment on lines +3807 to 3808
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the change is hacky and was meant to be temporary. I'd appreciate any suggestions on replacing it.

I think I will want to the replace the mitogen.exit_status variable with a less general fakessh.exit_status variable, and add a separate self.config['term_on_exit']option to control whether SIGTERM is sent when the broker shuts down.


def _on_shutdown_msg(self, msg):
Expand Down Expand Up @@ -3859,9 +3859,11 @@ def _setup_master(self):

in_fd = self.config.get('in_fd', 100)
in_fp = os.fdopen(os.dup(in_fd), 'rb', 0)
out_fp = os.fdopen(os.dup(self.config.get('out_fd', 1)), 'wb', 0)
# Avoid closing in_fd until after duplicating out_fd in case
# (in_fd == out_fd) are the same bidirectional socket fd
os.close(in_fd)

out_fp = os.fdopen(os.dup(self.config.get('out_fd', 1)), 'wb', 0)
self.stream = MitogenProtocol.build_stream(
self.router,
parent_id,
Expand Down
Loading