Commit Graph

180 Commits (2ecc6f43a4492101d85c07935bc735932849d149)

Author SHA1 Message Date
David Wilson 7cf2edc3a8 ansible: Support many more common playbook variables. 7 years ago
David Wilson ff617824a1 ansible: fix some flake8 errors
* Unused imports
* Undefined names in helpers.py
* Copyright header wrapping
7 years ago
Alex Willmer 33781aba2c core: Correct naming of Stream.sent_modules
Fixes #90
7 years ago
Alex Willmer d4a546dcbc parent: Fix ModuleForwarder not sending related packages
Found due to a LGTM warning about unused loop variable (related). As far
as I can tell the callback was sending fullname multiple times. KeyError
check added because I found NestedTest failed - mitogen.parent had
mitogen as one of it's related, and mitogen was not in the cache.

Refs #61
7 years ago
Alex Willmer 227cd3aa60 ssh, sudo: Remove redundant else clause on bootstrap loop
Since the for loops don't contain any break statements the StreamErrors
will always be raised when the loop completes without the method
resturning.

See https://lgtm.com/rules/5980098/

Refs #61
7 years ago
Alex Willmer a1aab30e63 core: Implement Dead.__ne__ & Dead.__hash__
Both these addtions are to address warnings in
https://lgtm.com/projects/g/dw/mitogen/alerts/?mode=list. Namely that if
a class defines an equality method then it should also define an
inequality and a hash method.

Refs #61
7 years ago
Alex Willmer 4b373c421b core: Standardise type of Importer.whitelist
This seemed a reasonable streamlining, but I'm happy to be overruled.
7 years ago
Alex Willmer ecaa8609f3 core: Add docstring to is_blacklisted_import()
This documents the existing behaviour, which may not be the intended.
7 years ago
David Wilson 5855f1739f core: Handle unpicklable data in dispatch_calls()
Sending just via .call_async() would previously crash the child, now it
generates CallError like intended.
7 years ago
Alex Willmer 8513b331b7 Use Pythabsoluteon 2.4 compatible module import
Python 2.4 does not support explicit relative imports. They were added
at Python 2.5, along with `from __future__ import absolute_import`.

On 2.x this will mean the import is first (implicitly) tried relative,
but on 3.x it will always be tried absolute.

Fixes #92
7 years ago
David Wilson 5036a9448f Add Docker method. 7 years ago
David Wilson d4169557f1 Fix some more Python 2.4 syntax 7 years ago
Alex Willmer 2dcab3fe06 master: Reword ModuleFinder.find_realted*() docstrings
Hopefully these are correct, and clearerabout the
behaviour/pre-conditions of these methods.
7 years ago
Alex Willmer c2405369d2 ModuleFinder: Get stdlib paths by sys.prefix, sys.real_prefix etc.
I took the liberty of renaming ModuleFinder.STDLIB_DIRS to
_STDLIB_PATHS, since it felt like an implementation detail that
shouldn't be baked into a public API and stdlib can also be imported
from e.g. a zip file.

I also changed it to a set to handle any duplicates.

Fixes #86
7 years ago
David Wilson b221eaaa10 ansible: log call timings 7 years ago
David Wilson afc8697288 core: Ensure add_handler() callbacks really receive _DEAD on shutdown 7 years ago
David Wilson 91116810a1 ansible: delete utils.py and promote cast() to mitogen.utils 7 years ago
David Wilson 18eaf14dca ansible: migrate logging variables into utils. 7 years ago
David Wilson 5d8cb0f5fb ansible: document the connection class. 7 years ago
David Wilson 020036f807 core: add a nasty hack for Ansible modules. 7 years ago
David Wilson fa804c7c80 parent: simplify route() call
Doesn't need to go via defer() since it's always running on the broker
thread.
7 years ago
David Wilson bdd8648bae ssh: enable compression by default
Using the same test as in 7af97c0365,
transmitted wire bytes drops from 135,531 to 133,071 (-1.81%), while
received drops from 21,073 to 14,775 (-30%).

Combined, both changes shave 13,914 bytes (-8.6%) off aggregate
bandwidth usage.

Make it configurable as compression hurts in some scenarios.
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 71a6b9e32a master: Select.all() sugar 7 years ago
David Wilson b543b84e80 importer: share blacklist logic between master/parent 7 years ago
David Wilson 8ec6ae1da0 importer: module whitelist/blacklist support
Hoped to avoid it, but it's the obvious solution for Ansible.
7 years ago
David Wilson 43ba1c76dc core: wrap selects in EINTR handlers
This isn't nearly enough, but it catches the most common victim of
EINTR.
7 years ago
David Wilson aafe458a13 core: #39: don't call logging framework when logging is disabled
It looks ugly as sin, but this nets about a 20% drop in user CPU time,
and close to 15% increase in throughput.

The average log call is around 10 opcodes, prefixing with '_v and' costs
an extra 2, but both are simple operations, and the remaining 10 are
skipped entirely when _v or _vv are False.
7 years ago
David Wilson 2ce71b338b unix: add small explainer note until real docs exist 7 years ago
Alex Willmer 3261c561dd Fix AttributeError in mitogen.core.Context.send_await()
As of adc8fe3aed Receiver objects do not
have a get_data() method and Receiver.get() does not unpickle the
message.
7 years ago
David Wilson 6905dc4e8d master: use queue-like Latch in Select() too. 7 years ago
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.
7 years ago
David Wilson e6a107c5aa core: replace Queue with Latch
On Python 2.x, operations on pthread objects with a timeout set actually
cause internal polling. When polling fails to yield a positive result,
it quickly backs off to a 50ms loop, which results in a huge amount of
latency throughout.

Instead, give up using Queue.Queue.get(timeout=...) and replace it with
the UNIX self-pipe trick. Knocks another 45% off my.yml in the Ansible
examples directory against a local VM.

This has the potential to burn a *lot* of file descriptors, but hell,
it's not the 1940s any more, RAM is all but infinite. I can live with
that.

This gets things down to around 75ms per playbook step, still hunting
for additional sources of latency.
7 years ago
David Wilson beb16d0db6 master: helper functions to force disconnect everything 7 years ago
David Wilson 9b5d0a9b97 service: initial version 7 years ago
David Wilson a35fcf44cc ansible: restructure to avoid intermediate imports 7 years ago
David Wilson 75a78c9ff4 ansible: connection plugin v2
Now featuring one roundtrip per module invocation.
7 years ago
David Wilson f3e51a7b18 core: CALL_FUNCTION should check auth_id, not src_id 7 years ago
David Wilson f001eba23e ansible: Merge module runner into helpers.py. 7 years ago
David Wilson 67d4c13ffa Remove old TCP draft. 7 years ago
David Wilson 32f6ee7d43 issue #40: mitogen.unix initial implementation. 7 years ago
David Wilson 37e3151be8 fakessh: restore unpickle() semantics. 7 years ago
David Wilson e63e9d299e docs: add Message documentation 7 years ago
David Wilson 10230f62dd core: Message.reply() helper function 7 years ago
David Wilson 6fc8fa5b22 core: Don't crash if a stream is missing a side. 7 years ago
David Wilson 9238e09ae8 core: Restore behaviour of unpickling Router-specific Context subclass 7 years ago
David Wilson dd088908df select: clean up API. 7 years ago
David Wilson df07e47d24 core: de-munge Message.unpickle() vs. Receiver.get(). 7 years ago
David Wilson a39cd44bf2 core: add auth_id field. 7 years ago
David Wilson a54c96faae core: remove unused SecurityError. 7 years ago