Commit Graph

21 Commits

Author SHA1 Message Date
David Wilson ec176bf1f8 tests: unittest2 import behaviour appears to differ between 2/3.
In 2 the module is loaded as __main__
In 3 it has its actual name.
2018-07-07 14:55:47 +01:00
David Wilson 410016ff47 Initial Python 3.x port work.
* ansible: use unicode_literals everywhere since it only needs to be
  compatible back to 2.6.
* compat/collections.py: delete this entirely and rip out the parts of
  functools that require it.
* Introduce serializable Kwargs dict subclass that translates keys to
  Unicode on instantiation.
* enable_debug_logging() must set _v/_vv globals.
* cStringIO does not exist in 3.x.
* Treat IOLogger and LogForwarder input as latin-1.
* Avoid ResourceWarnings in first stage by explicitly closing fps.
* Fix preamble_size.py syntax errors.
2018-07-07 14:55:47 +01:00
David Wilson 7c88e4d013 Move _DEAD into header, autogenerate dead messages
This change blocks off 2 common scenarios where a race condition is
upgraded to a hang, when the library could internally do better.

* Since we don't know whether the receiver of a `reply_to` is expecting
  a raw or pickled message, and since in the case of a raw reply, there
  is no way to signal "dead" to the receiver, override the reply_to
  field to explicitly mark a message as dead using a special handle.

  This replaces the serialized _DEAD sentinel value with a slightly
  neater interface, in the form of the reserved IS_DEAD handle, and
  enables an important subsequent change: when a context cannot route a
  message, it can send a generic 'dead' reply back towards the message
  source, ensuring any sleeping thread is woken with ChannelError.

  The use of this field could potentially be extended later on if
  additional flags are needed, but for now this seems to suffice.

* Teach Router._invoke() to reply with a dead message when it receives a
  message for an invalid local handle.

* Teach Router._async_route() to reply with a dead message when it
  receives an unroutable message.
2018-04-22 00:17:27 +01:00
Alex Willmer a22294dda9 call_function_test: Fix assumption that we run as a script 2018-04-01 01:23:13 +01:00
David Wilson 80a97fbc9b core: Rename Sender.put() to Sender.send().
Been annoying me for months.
2018-03-29 15:43:48 +05:45
David Wilson 0f29baa077 core: support pickling senders, Receiver.to_sender()
CC @moreati, in case this impacts you
2018-03-29 15:32:40 +05:45
Alex Willmer 7e01c5bed5 Import and use unittest2 without aliasing it 2018-03-19 21:58:28 +05:45
Alex Willmer e8e023ce59 Use specific TestCase assertions throughout tests
e.g. assert x == y -> self.assertEqual(x, y);
self.assertTrue(isinstance(x, y)) -> self.assertIsInstance(x, y)

These specific methods give more useful errors in the case of a test
failure.
2018-03-19 21:58:28 +05:45
Alex Willmer 17da6e9998 Use unittest2 in all tests
This allows using features such as TestCase,assertIsInstance on Python
2.6 and earlier.
2018-03-19 21:58:27 +05:45
David Wilson b7a9aa46cf core: More robust shutdown
Now there is a separate SHUTDOWN message that relies only on being
received by the broker thread, the main thread can be hung horribly and
the process will still eventually receive a SIGTERM.
2018-03-19 21:35:37 +05:45
David Wilson 32d029ed75 Add test that hangs the main thread during shutdown. 2018-03-19 21:35:37 +05:45
David Wilson 3285fc2f75 Implement test_aborted_on_local_context_disconnect 2018-03-19 21:35:37 +05:45
David Wilson 118fe01be5 Use enhanced assertRaises in call_function_test.py. 2018-03-19 21:35:37 +05:45
David Wilson 9b13a4cc61 Fix 2 call_function_test failures. 2018-03-19 21:35:37 +05:45
David Wilson 2fed3613e9 Syntax error. 2018-03-19 21:35:36 +05:45
David Wilson f01e457d70 Allow running without py.test. 2018-03-19 21:35:35 +05:45
David Wilson 3c8c1f71a6 Update test. 2018-03-19 21:35:35 +05:45
David Wilson bdf4fcfbce Tidy up test. 2018-03-19 21:35:17 +05:45
David Wilson be9e55fe8c pickle: support Context(), use same unpickler everywhere.
* Support passing Context() objects in function calls and return values.
  Now the fakessh demo from the documentation index would work
  correctly.

* Since slaves can communicate with each other now, they should also use
  the same approach to unpickling as the master already used. Collapse
  away all the unpickle extension crap and hard-wire just the 3 types
  that support unpickling.
2018-03-19 21:35:17 +05:45
David Wilson 996d847731 Add some broken tests 2018-03-19 21:35:17 +05:45
David Wilson e75f1d8579 Add call_function_test, fix various exception bugs. 2018-03-19 21:35:17 +05:45