From ca63c26e0141fcf9a2d4018525a7182d7b7a3653 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Thu, 14 Feb 2019 14:58:55 +0000 Subject: [PATCH 1/6] core: Make Latch.put(obj=) optional. --- mitogen/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mitogen/core.py b/mitogen/core.py index cfdf996b..dcca2e91 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -2240,11 +2240,14 @@ class Latch(object): finally: self._lock.release() - def put(self, obj): + def put(self, obj=None): """ Enqueue an object, waking the first thread waiting for a result, if one exists. + :param obj: + Object to enqueue. Defaults to :data:`None` as a convenience when + using :class:`Latch` only for synchronization. :raises mitogen.core.LatchError: :meth:`close` has been called, and the object is no longer valid. """ From 14e6c6e49ee5321023605cbe0f2176bebe829f88 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Thu, 14 Feb 2019 15:00:17 +0000 Subject: [PATCH 2/6] docs: update Changelog. --- docs/changelog.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 222fee63..169e4095 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -139,6 +139,12 @@ Fixes 0.2.3 behaviour of defaulting to Kqueue in this case, but still prefer :func:`select.poll` if it is available. +Core Library +~~~~~~~~~~~~ + +* `ca63c26e `_: + :meth:`mitogen.core.Latch.put`'s `obj` argument was made optional. + Thanks! ~~~~~~~ From c0db283ac7e02723499b55ed7675252958e7b431 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Thu, 14 Feb 2019 21:21:45 +0000 Subject: [PATCH 3/6] docs: update copyright year. --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 3708a943..a6bc2cbc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -6,7 +6,7 @@ import mitogen VERSION = '%s.%s.%s' % mitogen.__version__ author = u'David Wilson' -copyright = u'2018, David Wilson' +copyright = u'2019, David Wilson' exclude_patterns = ['_build'] extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinxcontrib.programoutput'] html_show_sourcelink = False From ffdf31edd74babcc4dbb183b90554c04f187fbbe Mon Sep 17 00:00:00 2001 From: David Wilson Date: Thu, 14 Feb 2019 21:21:56 +0000 Subject: [PATCH 4/6] tests/bench: set process affinity in throughput.py. --- tests/bench/throughput.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/bench/throughput.py b/tests/bench/throughput.py index 896ee9ac..42604826 100644 --- a/tests/bench/throughput.py +++ b/tests/bench/throughput.py @@ -9,6 +9,7 @@ import time import mitogen import mitogen.service +import ansible_mitogen.affinity def prepare(): @@ -45,6 +46,8 @@ def run_test(router, fp, s, context): @mitogen.main() def main(router): + ansible_mitogen.affinity.policy.assign_muxprocess() + bigfile = tempfile.NamedTemporaryFile() fill_with_random(bigfile, 1048576*512) From e517810e5a3b1826e8ec1f53160345b8847c0a18 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Fri, 15 Feb 2019 12:18:28 +0000 Subject: [PATCH 5/6] tests: ensure serialization restrictions are in effect --- tests/serialization_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/serialization_test.py b/tests/serialization_test.py index 23c4a2d9..6cf5f8b7 100644 --- a/tests/serialization_test.py +++ b/tests/serialization_test.py @@ -8,11 +8,23 @@ from mitogen.core import b import testlib +class EvilObject(object): + pass + + def roundtrip(v): msg = mitogen.core.Message.pickled(v) return mitogen.core.Message(data=msg.data).unpickle() +class EvilObjectTest(testlib.TestCase): + def test_deserialization_fails(self): + msg = mitogen.core.Message.pickled(EvilObject()) + e = self.assertRaises(mitogen.core.StreamError, + lambda: msg.unpickle() + ) + + class BlobTest(testlib.TestCase): klass = mitogen.core.Blob From 7d0480e8bd410bd589328785f98457cf3f86bb55 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sat, 16 Feb 2019 16:53:49 +0000 Subject: [PATCH 6/6] core: increase cookie field lengths to 64-bit; closes #545. --- docs/changelog.rst | 7 +++++++ mitogen/core.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 169e4095..157ed902 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -139,6 +139,12 @@ Fixes 0.2.3 behaviour of defaulting to Kqueue in this case, but still prefer :func:`select.poll` if it is available. +* `#545 `_: an optimization + introduced in `#493 `_ caused a + 64-bit integer to be assigned to a 32-bit field on ARM 32-bit targets, + causing runs to fail. + + Core Library ~~~~~~~~~~~~ @@ -151,6 +157,7 @@ Thanks! Mitogen would not be possible without the support of users. A huge thanks for bug reports, testing, features and fixes in this release contributed by +`Fabian Arrotin `_, and `Petr Enkov `_. diff --git a/mitogen/core.py b/mitogen/core.py index dcca2e91..25732896 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -2140,7 +2140,7 @@ class Latch(object): return rsock, wsock COOKIE_MAGIC, = struct.unpack('L', b('LTCH') * (struct.calcsize('L')//4)) - COOKIE_FMT = 'Llll' + COOKIE_FMT = '>Qqqq' # #545: id() and get_ident() may exceed long on armhfp. COOKIE_SIZE = struct.calcsize(COOKIE_FMT) def _make_cookie(self):