Commit Graph

276 Commits (76ec4f201c6bd56d116b950888ae150301a8570b)

Author SHA1 Message Date
David Wilson 76ec4f201c issue #413: paper over harmless duplicate del_route()
Ideally it would only be called once, and in future maybe it can, but
right now we need to cope with these cases:

* Downstream parent notifies us of disconnection (DEL_ROUTE)
* We notify ourself of disconnection
* We notify ourself and so does downstream parent

It's case 3 that causes the error.
7 years ago
David Wilson cf97932fad core: dead messages have optional body, use it everywhere; closes #387. 7 years ago
David Wilson c09780aeb0 core: fix add_handler(respondent=..) memory leak
Closes #416.
7 years ago
David Wilson 10af266678 issue #406: attempt Broker cleanup in case of a crash. 7 years ago
David Wilson d1c2e7a834 issue #406: call Poller.close() during broker shutdown. 7 years ago
David Wilson e4280dc14a core: Don't crash in Waker.__repr__ if partially initialized. 7 years ago
David Wilson 87e8c45f76 core: fix minify_test regression introduced in 804bacdadb
The minifier can't handle empty function bodies, so the pass statements
are necessary.
7 years ago
David Wilson 16c364910a core: avoid redundant write() calls in Waker.defer()
Using _lock we can know for certain whether the Broker has received a
wakeup byte yet. If it has, we can skip the wasted system call.

Now on_receive() can exactly read the single byte that can possibly
exist (modulo FD sharing bugs -- this could be improved on later)
7 years ago
David Wilson 804bacdadb docs: move most remaining docstrings back into *.py; closes #388
The remaining ones are decorators which don't seem to have an autodoc
equivlent.
7 years ago
David Wilson 711aed7a4c core: split _broker_shutdown() out into its own function.
Makes _broker_main() logic much clearer.
7 years ago
David Wilson 1d32ed3b5a core: avoid shutdown() in IoLogger on WSL; closes #333. 7 years ago
David Wilson 5be9a55bf4 core: allow Context to be pickled by non-Mitogen pickler. 7 years ago
David Wilson a7ee23719a issue #388: move a ton of documentation back into the source 7 years ago
David Wilson 73cda2994f issue #333: add versioning, initial batch of poller tests
Now poller is start enough to know a start_receive() during an iteration
does not cause events yielded by that iteration to associate with the
wrong descriptor.

These changes are tangentially related to the associated ticket, but
event versioning is still the underlying issue.
7 years ago
David Wilson 1cbff1011e core: send dead message if max message size exceeded; closes #405 7 years ago
David Wilson 9ec360c26d core: split out & extend Broker.sync_call() 7 years ago
David Wilson 58d0a45738 issue #76: quieten routing errors.
Receiving DEL_ROUTE without a corresponding ADD_ROUTE is now legit
behaviour, so don't print an error in this case.

Don't print an error for dropped messages if the reply_to indicates the
sender doesn't care about a response (dead and no_reply)
7 years ago
David Wilson b9bafb78af issue #76: add stub DEL_ROUTE handler to core.py.
This handler knows how to fire 'disconnect' event on reception of a
DEL_ROUTE, and nothing more.
7 years ago
David Wilson babe3eec31 issue #76: record egress context IDs
Used in a subsequent change to broadcast DEL_ROUTE to potentially
interested children.
7 years ago
David Wilson d7d40f1123 issue #76: reduce Context duplication during unpickling
When unpickling a context, arrange for there to be a single instance
representing that context, managed by the corresponding router. This
context_by_id() was already in use by parent.py, it just needs to move
down.

This to eventually reach the point where a single Context exists that
needs 'disconnect' fired on it, so all sleeping receivers are definitely
woken.
7 years ago
David Wilson a7b1831ddf core: move IS_DEAD doc into core.py. 7 years ago
Alex Willmer 6da31c9dee docs: Remove unneeded backslash escapes
Python 3.x was emitting a DeprecationWarning. AFAICT there has been no
impact on the HTML rendering.
7 years ago
Yannig Perré 6828926a36 Kubernetes connection support for mitogen. 7 years ago
David Wilson 294f17e491 core: fix econtext on_start parameter, used by fork_test. 7 years ago
David Wilson 4d3873c784 core: call chains v3: abstract it into a new CallChain class. 7 years ago
David Wilson a3957d6aaf parent: add Context.forget_chain(). 7 years ago
David Wilson 37223adacd core: fix Dispatcher race introduced in 3a7815e5ca6255272334415916b6289378173859
It must be constructed before are messages pumped.
7 years ago
David Wilson 42b1b3d286 core: support mitogen_chain dispatcher option. 7 years ago
David Wilson 92c092d27b core: split Dispatcher out into own class. 7 years ago
David Wilson ba0b3af205 core: remove accidentally checked in debug crap (#337) 7 years ago
David Wilson c6159c9154 core: fix startup logging race. Closes #305. 7 years ago
David Wilson 7d62a53264 issue #337: ssh: disabling PTYs round 2: make it automatic. 7 years ago
David Wilson 2fcea4b199 add extra 'pass' statements to work around minify issues. 7 years ago
David Wilson 27b64a484b docs: document mitogen.core.CHUNK_SIZE. 7 years ago
David Wilson df5342af22 core: split out _internal_receive()
This is needed for libssh2.
7 years ago
David Wilson 442d88e3d7 docs: many more fixes/merges. 7 years ago
David Wilson a561fb79e5 docs: merge more docs back into mitogen/core.py. 7 years ago
David Wilson 81c8156965 Support LXD; closes #339. 7 years ago
David Wilson 5c573f7fcb ansible: insert short sleep when MITOGEN_PROFILING active.
Hacky, but works fine.
7 years ago
David Wilson d26fe5b993 issue #310: fix negative imports on Python 3.x.
On 3.x, Importer() can still have its methods called even if
load_module() raises ImportError.

Closes #310.
8 years ago
David Wilson f7e288fa25 core: fd 0/1 were accidently made non-blocking.
This breaks regular code. Triggered by a huge pprint() in the child to
stdout.
8 years ago
napkindrawing 745d72bb1d core: support for "doas" become_method 8 years ago
David Wilson 3a8ea930d7 core: fix NameError in Latch.put(), FileService exception 8 years ago
David Wilson 484d4fdb74 core: fix Latch socket sharing race.
If thread A is about to wake as thread B is about to sleep, and A loses
the GIL at an inopportune moment, it was possible for two latches to
share the same socketpair, causing wakeups routed to the wrong latch.

The pair was returned to the 'idle sockets' list before .recv() had been
called. This manifested as TimeoutError() thrown rarely with many active
threads and the host is heavily loaded (such as Travis CI).

Add more documentation and stop writing single wake bytes. Instead the
recipient's identity is written instead, making it simpler to detect
future bugs.
8 years ago
David Wilson 29f15c236c core: remove needless size prefix from core_src_fd.
I think this is brainwrong held over from an early attempt to write the
duplicate copy of core_src on stdin.
8 years ago
David Wilson 04e138e060 core: fix serialization of empty bytes() on 3.x. 8 years ago
David Wilson ff2f44b046 core: reduce chance of Latch.read()/write()/close() race.
Previously it was possible for a thread to call Waker.defer() after
Broker has torns its Waker down, and the underlying file descriptor
reallocated by the OS to some other component.

This manifested as latches of a subsequent test invocation receiving the
waker byte (' ') rather than their expected byte '\x7f'.

This doesn't fix the problem, it just significantly reduces the chance
of it occurring. In future Side.write()/read()/close() must be
synchronized with a lock.

Previously the problem could be reliably triggered with:

    while :; do
        python tests/call_function_test.py -vf CallFunctionTest.{test_aborted_on_local_broker_shutdown,test_aborted_on_local_context_disconnect}
    done
8 years ago
David Wilson e24eddb1ce core: move Latch docs back inline. 8 years ago
David Wilson 42276f158b core: log the data received on the latch file handle. 8 years ago
David Wilson a52064a24f core: reordered find_module() test was broken (again)
e81b3bd0652b5eb125eb224ceca281b9d540dd5e

The whitelist check must happen /after/ the other checks, otherwise we
unconditionally retunr self for crap like 'ansible.module_utils.json'.
8 years ago