- 24 Mar, 2018 23 commits
-
-
David Wilson authored
Mostly just to avoid embarrassing function size, but it may come in useful for testing later.
-
David Wilson authored
-
David Wilson authored
-
David Wilson authored
-
David Wilson authored
This is a partial fix to a general problem: deciding which bits of state to keep from the parent, and which to clear out. When forking from a heavily threaded process, there will be 2x$n_threads fds just sitting around doing nothing, due to Latch use in the parent. We can't just close all nonstandard fds post-fork, since user code may be expecting some FDs to be preserved.
-
David Wilson authored
-
David Wilson authored
This permits graceful shutdown of individual contexts, without tearing down everything. Update mitogen.parent.Stream to also wait for the child to exit, to prevent the buildup of zombie processes. This introduces a blocking wait for process exit on the Broker thread, let's see if we can get away with it. Chances are reasonable that it'll cause needless hangs on heavily loaded machines.
-
David Wilson authored
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.
-
David Wilson authored
-
David Wilson authored
nested_test was failing due to the recent change to centralize O_CLOEXEC, since stdout and stderr were being marked as non-inheritable. That meant child processes would start with no stdout/stderr, triggering a race between Waker opening its pipes, and IoLogger dup2'ing its pipes over the stdio handles. Since the stdio handles were closed, Waker would receive one of them as one end of its pipe, and consequently have it overwritten by IoLogger. When IoLogger dups over the top of fd 2, it becomes possible for Waker.on_read() to be called due to pipe's other end to be closed, causing an OSError exception with errno EAGAIN to appear.
-
David Wilson authored
-
David Wilson authored
Any long-running system call may suffer EINTR, so arrange for all IO calls to be wrapped in the restart loop.
-
David Wilson authored
This eliminates Context.on_disconnect() and instead moves its functionality to a signal wired up by ExternalContext.main(). It leaves mitogen.master.Context is in a better condition to move into mitogen.parent where it belongs.
-
David Wilson authored
-
David Wilson authored
-
David Wilson authored
-
David Wilson authored
-
David Wilson authored
-
David Wilson authored
* Split setup_globals() from setup_package() and make package setup optional (fork never needs it -- synthetic package already exists in children and the real package exists in masters). * Add main() parameter to allow passing in the existing Importer instance. In forks from children, this means we inherit all the cached module state along with the __loader__ used to import any existing modules.
-
David Wilson authored
This is a hacky layering violation, but it seems the simplest approach for now: fork needs access to Router, in order to recover the existing Importer instance.
-
David Wilson authored
-
David Wilson authored
-
David Wilson authored
notice_stream() does that already.
-
- 23 Mar, 2018 7 commits
-
-
David Wilson authored
-
David Wilson authored
Now it's handled in Side() constructor, it can disappear elsewhere.
-
David Wilson authored
-
David Wilson authored
-
David Wilson authored
-
David Wilson authored
This abstracts the pattern found in parent.ModuleForwarder and to a lesser degree master.ModuleResponser. We can probably use it in those contexts later.
-
David Wilson authored
Not sure why this wasn't done before, seems it should have always been this way, and can't see any reason it wasn't. Without it, many fds are leaked into at least .local() children. Closes #163.
-
- 22 Mar, 2018 4 commits
-
-
David Wilson authored
-
David Wilson authored
It's entirely unclear how test_aborted_on_local_context_disconnect ever passed, but it was broken by the previous commit.
-
David Wilson authored
* 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
-
David Wilson authored
-
- 21 Mar, 2018 6 commits
-
-
David Wilson authored
* Explicitly name every test to run, I have lots of unchecked in stuff * Allow SIGINT to stop the process
-
David Wilson authored
-
David Wilson authored
In order to support a .remove() method, to prevent a minor but annoying (log visible) memory leak while running the tests.
-
David Wilson authored
-
David Wilson authored
Avoids a roundtrip for every fork.
-
David Wilson authored
-