Commit Graph

54 Commits

Author SHA1 Message Date
David Wilson 5bdb745f07 docs: howitworks tweaks 2018-11-02 15:14:00 +00:00
David Wilson f3e19d81da docs: reorder sections 2018-10-23 23:26:12 +01:00
David Wilson bd71a2760e docs: describe disconnect propagation; closes #76. 2018-10-23 23:16:48 +01:00
David Wilson a7b1831ddf core: move IS_DEAD doc into core.py. 2018-10-03 14:45:23 +01:00
David Wilson dfc67b89fd docs: some more cleanups
- add faulthandler/thread stacks to changelog.
- various api.rst cleanups.
- docs: explain chain_id in howitworks.
2018-09-10 18:33:44 +01:00
David Wilson 4d3873c784 core: call chains v3: abstract it into a new CallChain class. 2018-09-09 18:51:03 +01:00
David Wilson 442d88e3d7 docs: many more fixes/merges. 2018-08-18 16:44:00 +01:00
David Wilson d6126a9516 issue #275: parent/ssh: centralize EC0_MARKER and change it for ssh.py.
Must maintain a minimum buffer length prior to deciding whether we have
an interesting token, and 'EC0' is too short for that.
2018-06-25 01:36:31 +01:00
David Wilson d2714752ee docs: tidy ups 2018-05-25 13:55:58 +01:00
David Wilson b7ab473343 issue #186: split handle list up so it makes sense 2018-05-13 17:05:09 +01:00
David Wilson d1a22cb5d4 issue #186: parent: implement FORWARD_MODULE.
To support detach, we must be able to preload the target with every
module it will need prior to detachment. This implements the
intermediary part of the process (i.e. the Ansible fork parent) --
receiving LOAD_MODULE/FORWARD_MODULE pairs and ensuring they reach the
child.
2018-05-13 16:58:47 +01:00
David Wilson 7f1060f54a issue #186: initial version of subtree detachment. 2018-05-03 01:11:14 +01:00
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.
2018-04-22 00:17:27 +01:00
David Wilson 6a74edce6b issue #155: parent: move master.Context into parent.
The Context and Router APIs for constructing children and making
function calls should be available in every parent context, as user code
wants to have access to the same API.
2018-03-24 19:19:45 +05:45
David Wilson 54ff1c90fa issue #155: add DEL_ROUTE, propagate ADD_ROUTE upwards
* IDs are allocated by the parent responsible for contructing a new
  child, using ALLOCATE_ID to the master as necessary to allocate new ID
  ranges.

* ADD_ROUTE is sent up the tree rather than down. This permits
  construction of the new context to complete concurrent to parent
  contexts learning about its existence. Since all streams are strictly
  ordered, it's not possible for any parent to observe messages from the
  new context prior to arrival of an ADD_ROUTE from the parent notifying
  of its existence.

  If the new context, for example, implements an Ansible async task, its
  parent can start executing that without waiting for any synchronous
  confirmation from any parent or the master.

* Since routes propagate up, it's no longer possible for a plain
  non-parent child to ever receive ADD_ROUTE, so that code can be moved
  out of core.py and into parent.py (-0.2kb compressed).

* Add a .routes attribute to parent.Stream, and respond to disconnection
  signal on the stream by propagating DEL_ROUTE for any ADD_ROUTE ever
  received from that stream.

* Centralize route management in a new parent.RouteMonitor class
2018-03-22 11:56:24 +05:45
David Wilson 1ed86774b5 issue #156: document select exception 2018-03-21 09:23:54 +05:45
David Wilson 20f5d89dfa issue #156: fix several more races
* Don't need to sleep if queue>sleepers, can just pop the right queue
  element and return it.

* If queue>sleeping and waking==sleeping, no mechanism existed to ensure
  a thread newly added to sleeping would ever be woken. Above change
  fixes that.

* Cannot trust select() return value, scheduler might sleep us
  indefinitely while put() writes a byte.

* Sleeping threads didn't pop FIFO, they popped in whatever order
  scheduler woke them up. Must recover index and use it to pick the pop
  index.
2018-03-20 14:53:19 +05:45
David Wilson 526b0a514b issue #156: prevent Latch.close() triggering spurious wakeups 2018-03-20 13:14:51 +05:45
David Wilson 18e2977baf docs: annoying phrasing 2018-03-20 13:05:41 +05:45
David Wilson 2c22c41819 issue #156: don't decrement `waking` if we timed out rather than being woken. 2018-03-20 13:02:46 +05:45
David Wilson 07a8994ff5 issue #156: waking thread result dictionary with an integer. 2018-03-20 12:55:55 +05:45
David Wilson b5398bd17f issue #156: docs typo 2018-03-20 09:12:50 +05:45
David Wilson 512ff77a46 issue #156: prevent non-sleeping threads from starving sleeping threads.
See new docs
2018-03-20 09:12:45 +05:45
David Wilson 148ce1d703 issue #155: increase context ID width to 32 bits
Needed to make large range allocations (1000 per ALLOCATE_ID roundtrip)
feasible.
2018-03-19 21:58:35 +05:45
David Wilson 03e51fdaa7 docs: mitogen.core.Latch docs 2018-03-19 21:58:32 +05:45
David Wilson 20afa5b90c Latch v2: combined queue + one self-pipe-per-thread
Turns out it is far too easy to burn through available file descriptors,
so try something else: self-pipes are per thread, and only temporarily
associated with a Lack that wishes to sleep.

Reduce pointless locking by giving Latch its own queue, and removing
Queue.Queue() use in some places.

Temporarily undo merging of of Waker and Latch, let's do this one step
at a time.
2018-03-19 21:58:29 +05:45
David Wilson a39cd44bf2 core: add auth_id field. 2018-03-19 21:58:28 +05:45
David Wilson 592ebd59c2 docs: reorder sections 2018-03-19 21:58:28 +05:45
David Wilson dee856f6f4 docs: remove obsolete warning 2018-03-19 21:58:28 +05:45
David Wilson 4d9d21c808 docs: fix typo 2018-03-19 21:58:28 +05:45
David Wilson 4a6d55ced6 docs: vastly simplify importer concurrency docs 2018-03-19 21:58:28 +05:45
David Wilson 984b39180e importer: Beginnings of howitworks section. 2018-03-19 21:58:28 +05:45
David Wilson 038ab04908 docs: convert paragraph to footnote. 2018-03-19 21:58:27 +05:45
David Wilson e3d2c8d649 issue #49: update howitworks.rst for command line change 2018-03-19 21:58:27 +05:45
David Wilson cf0668b2b1 docs: Add warning to preloading section. 2018-03-19 21:58:27 +05:45
David Wilson ac7cada323 docs: more getting started guide 2018-03-19 21:58:27 +05:45
David Wilson ffa063cc01 docs: annother barriage of cross-reference fixes. 2018-03-19 21:58:25 +05:45
David Wilson 9372d2c3de docs: Fix up tons of references, document trust chain 2018-03-19 21:35:38 +05:45
David Wilson 051285437f importer: module preloading docs 2018-03-19 21:35:38 +05:45
David Wilson dcc45bc7de docs: Get started on Getting Started 2018-03-19 21:35:37 +05:45
David Wilson b7a9aa46cf core: More robust shutdown
Now there is a separate SHUTDOWN message that relies only on being
received by the broker thread, the main thread can be hung horribly and
the process will still eventually receive a SIGTERM.
2018-03-19 21:35:37 +05:45
David Wilson 79dd00db5a master: hack to avoid executing __main__. 2018-03-19 21:35:37 +05:45
David Wilson 976c643f21 docs: remove note, unpickling can no longer trigger module loads 2018-03-19 21:35:37 +05:45
David Wilson decc9a900c docs: s/random/pseudorandom/ 2018-03-19 21:35:37 +05:45
David Wilson 83f8f1863e docs: fix pickler docs, begin relabelling master/slave->parent/child 2018-03-19 21:35:37 +05:45
David Wilson 4327baabfa docs: remove final references to call_with_deadline(). 2018-03-19 21:35:37 +05:45
David Wilson dd69b8feeb docs: with_context element is replaced by a decorator. 2018-03-19 21:35:37 +05:45
David Wilson a81f804e92 Accidentally hecked in incomplete paragraph. 2018-03-19 21:35:37 +05:45
David Wilson f1d82c7284 More API documentation. 2018-03-19 21:35:36 +05:45
David Wilson 9d2a11e70f Fix function reference. 2018-03-19 21:35:36 +05:45