Commit Graph

801 Commits (3613162bc04bc4a7229a46f580f65608cccecc07)
 

Author SHA1 Message Date
David Wilson 7f4368db87 docs: pad out signal handlers note 6 years ago
David Wilson c34f8dbef3 core: Fix Receiver.__iter__ loop termination.
Since the Message refactoring from a few weeks back, __iter__ has had
nothing to throw ChannelError if the remote sent _DEAD.
6 years ago
David Wilson 671f753207 core: cache result of unpickling message. 6 years ago
David Wilson 5b87d10ae6 core: clean up no longer useful Latch.__repr__
Those fields are always None since the recent fork cleanup work.
6 years ago
David Wilson d4bc44468b core: fix crash in fork stress test
14:50:04 E mitogen: mitogen.fork.Stream('fork.7431') crashed
Traceback (most recent call last):
  File "/home/dmw/src/mitogen/mitogen/core.py", line 1287, in _call
    func(self)
  File "/home/dmw/src/mitogen/mitogen/core.py", line 758, in on_receive
    return self.on_disconnect(broker)
  File "/home/dmw/src/mitogen/mitogen/parent.py", line 370, in on_disconnect
    super(Stream, self).on_disconnect(broker)
  File "/home/dmw/src/mitogen/mitogen/core.py", line 721, in on_disconnect
    fire(self, 'disconnect')
  File "/home/dmw/src/mitogen/mitogen/core.py", line 162, in fire
    return [func(*args, **kwargs) for func in signals.get(name, ())]
  File "/home/dmw/src/mitogen/mitogen/core.py", line 1160, in <lambda>
    listen(stream, 'disconnect', lambda: self.on_stream_disconnect(stream))
  File "/home/dmw/src/mitogen/mitogen/core.py", line 1142, in on_stream_disconnect
    for context in self._context_by_id.itervalues():
RuntimeError: dictionary changed size during iteration
6 years ago
David Wilson 95d50adb14 unix: simplify return statements. 6 years ago
David Wilson d68833757b docs: slightly bikeshed last testimonial 6 years ago
David Wilson adf527440f issue #155: parent: split out make_call_msg(). 6 years ago
dw d23a6174a2
Merge pull request #167 from danielcompton/patch-1
Add testimonial from Clojars
6 years ago
David Wilson 0dbb63ae3d docs: typo 6 years ago
David Wilson b254373cd7 docs: add local task serialization risk 6 years ago
David Wilson 7698f86a9f Whups, don't always enable profiling in mitogen.main() 6 years ago
David Wilson 52d980ad58 issue #155: fork: nop out get_boot_command, it's become quite expensive
-16% reduction in fork cost.
6 years ago
David Wilson e7c98e3bda Have mitogen.main(profiling=True) effect the master process too 6 years ago
David Wilson a868498469 Replace assertions with fixed checks; closes #157. 6 years ago
David Wilson 4dc001f496 parent: fire disconnect upon receiving DEL_ROUTE for context
This lets context.shutdown(wait=True) succeed in the master or any
parent.
6 years ago
David Wilson 862ec21160 core: allow shutdown triggered by any parent, not just immediate parent 6 years ago
David Wilson 0f08783330 core: fix NameError on disconnect 6 years ago
David Wilson 198bec3320 issue #168: ansible: Mitogen must also ignore the extra arguments. 6 years ago
David Wilson 26051caf4c ansible: Pass through connection loader kwargs; closes #168 6 years ago
David Wilson 749eddac71 ansible: fix flake8 errors in helpers.py. 6 years ago
Daniel Compton 871b853b59
Add testimonial from Clojars 6 years ago
David Wilson 2813d1a968 docs: update 6 years ago
David Wilson 3e384db7c2 service: add basic security policy types. 6 years ago
David Wilson 2ea65420d0 issue #155: fork.py v2, now with full resource cleanup 6 years ago
David Wilson 872181bebd issue #155: core: implement Side._on_fork()
Central mechanism for deleting all non-Latch file descriptors belonging
to the parent process during fork().
6 years ago
David Wilson 80642ed9ec issue #155: core: remove one duplicate set_cloexec(). 6 years ago
David Wilson cb71ce94c4 issue #155: core: be more careful reconfiguring stdio
Many dragons present!
6 years ago
David Wilson 443c94eb39 issue #155: core: prevent set_cloexec() use on standard handles 6 years ago
David Wilson 41ae6623c6 issue #155: parent: generic name generation
Let us override a class attribute to specify prefix from fork.py, rather
than reimplement the same logic.
6 years ago
David Wilson 22cc1a3689 issue #155: core: refactor Latch to avoid TLS use
TLS destructors are not called after fork, therefore we must explicitly
track a global list of free file descriptors, and arrange for that list
to explicitly be destroyed from fork.py.
6 years ago
David Wilson 2cf9edc895 issue #155: core: ensure reused Importer gets new Context reference.
More hacky layering violations.. force Importer's _context attribute to
our new parent.
6 years ago
David Wilson cd5b37ea5b core: Use Side.read() rather than bare os.read(). 6 years ago
David Wilson 1155de85af issue #155: parent: propagate context name too.
This allows context_by_id() in the master to succeed in returning a
Context with a .name matching the context's name, needed for correct
logging.

Previously this would have logged the empty string, because the master
had no mechanism to know the name of a context created by a child.
6 years ago
David Wilson 5579ac936b issue #155: docs: more fork() liability warnings 6 years ago
David Wilson f457f54758 docs: fix formatting 6 years ago
David Wilson d370290687 docs: one more warning 6 years ago
David Wilson 03e08e25fd docs: put huge liability notice in fork() docs. 6 years ago
David Wilson 19d17982f3 core: Split blocking and non-blocking Latch.get()
Mostly just to avoid embarrassing function size, but it may come in
useful for testing later.
6 years ago
David Wilson cba3347556 issue #155: move connection factories to parent.py. 6 years ago
David Wilson 972f77c6b5 parent: have close_nonstandard_fds() ask OS for FD_MAX 6 years ago
David Wilson 721caafb33 core: Do not decrement Latch._waking if we weren't woken. 6 years ago
David Wilson f6c24ab615 issue #155: don't inherit TLS state in mitogen.fork
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.
6 years ago
David Wilson 67e0a4fe59 issue #155: add mitogen.fork to Importer list 6 years ago
David Wilson 48351a1889 issue #155: parent: support Context.shutdown(), reap children on exit.
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.
6 years ago
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.
6 years ago
David Wilson 447353ecb8 docs: ansible.rst: note multi-host perf isn't great right now 6 years ago
David Wilson f752653e77 core: IoLogger: don't set O_CLOEXEC on standard handles
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.
6 years ago
David Wilson 0eeba2eaa8 core: include fds in Waker repr 6 years ago
David Wilson 7a061fe18b core: merge restart() into io_op()
Any long-running system call may suffer EINTR, so arrange for all IO
calls to be wrapped in the restart loop.
6 years ago