Commit Graph

17 Commits (d3fe24a4f6bdcfe4d48c1b67e4da08765a7abc9a)

Author SHA1 Message Date
David Wilson 4c5e13bf87 core: add Stream.pending_bytes() accessor. 7 years ago
David Wilson 7c88e4d013 Move _DEAD into header, autogenerate dead messages
This change blocks off 2 common scenarios where a race condition is
upgraded to a hang, when the library could internally do better.

* Since we don't know whether the receiver of a `reply_to` is expecting
  a raw or pickled message, and since in the case of a raw reply, there
  is no way to signal "dead" to the receiver, override the reply_to
  field to explicitly mark a message as dead using a special handle.

  This replaces the serialized _DEAD sentinel value with a slightly
  neater interface, in the form of the reserved IS_DEAD handle, and
  enables an important subsequent change: when a context cannot route a
  message, it can send a generic 'dead' reply back towards the message
  source, ensuring any sleeping thread is woken with ChannelError.

  The use of this field could potentially be extended later on if
  additional flags are needed, but for now this seems to suffice.

* Teach Router._invoke() to reply with a dead message when it receives a
  message for an invalid local handle.

* Teach Router._async_route() to reply with a dead message when it
  receives an unroutable message.
7 years ago
David Wilson e43c6c531b Mostly implement hybrid TTY/socket mode for sudo and SSH.
Presently there is still no mechanism to add :attr:`tty_stream` to the
multiplexer after connection is successful, but for now it's not
expected that anything will be logged to it anyway.

Closes #148.
7 years ago
David Wilson 8676c40674 core: make _start_transmit / _stop_transmit async-only
For now at least, these APIs are always used in an asynchronous context,
so stop using the defer mechanism.
7 years ago
David Wilson 110fdf24cd docs: add mitogen.fork.Stream to internals.rst 7 years ago
David Wilson 8aada2646c core: support throwing LatchError in every sleeping thread
This is to allow Select() to be used as a generic queueing primitive
that supports graceful shutdown.
7 years ago
David Wilson 03e51fdaa7 docs: mitogen.core.Latch docs 7 years ago
David Wilson 4d940f08ae importer: drop redundant prefix from pkg_present
For the 52 submodules of ansible.modules.system, this produced a 1602
byte pkg_present list. After stripping it becomes 406 bytes, and the
entire LOAD_MODULE size drops from 1988 bytes to 792 bytes (-60%).

For the 68 submodules of ansible.module_utils, 1902 bytes pkg_present
becomes 474 bytes (-75%), and LOAD_MODULE size drops from 2867 bytes to
1439 bytes (-49%).

In a simple test running Ansible's "setup" module followed by its "apt"
module, wire bytes sent drops from 140,357 to 135,531 (-3.4%).
7 years ago
David Wilson 07d4d799f1 Add mitogen.main() decorator mainly for docs and demo use. 7 years ago
David Wilson 984b39180e importer: Beginnings of howitworks section. 7 years ago
David Wilson 9372d2c3de docs: Fix up tons of references, document trust chain 7 years ago
David Wilson ec66152e37 docs: better io_op doc, move Side docs to Sphinx. 7 years ago
David Wilson 0767abf26f docs: move BasicStream docs into Sphinx. 7 years ago
David Wilson 416ab90e02 docs: Fix index generation everywhere. 7 years ago
David Wilson 04ea5306e9 Document a bunch of mitogen.master and move more docstrings into Sphinx. 7 years ago
David Wilson b809d43865 Move more docstrings out of core.py. 7 years ago
David Wilson e7ff6259a3 Initial commit. 7 years ago