Created
November 5, 2014 17:17
-
-
Save dt/a5d72f580b3fb9a60466 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# def slow_identity_func(i): | |
# import time | |
# time.sleep(i[0]) | |
# return i[1] | |
# def test_multiproc_map_timeout(self): | |
# context = create_context() | |
# msg = 'subproc_map result still not ready...' | |
# counting_log = MockLogger(count_messages_matching=set([msg])) | |
# context._log = counting_log | |
# # Try to keep these times as short as possible, to avoid making running tests take forever. | |
# # However min sleep is ~10-15ms, so "longer" sleeps need to be ~50ms to be safe. | |
# # First we'll have context.subproc_map check more often and use a "long" sleep in slow func. | |
# context._MINUTE = .01 # short wait | |
# res1 = context.subproc_map(slow_identity_func, [(.05, 'a')]) # "long" sleep | |
# # We should have seen messages about waiting for results. | |
# loops = counting_log.counts[msg] | |
# self.assertTrue(loops > 1) | |
# self.assertEquals(res1, ['a']) | |
# # Now invert short and long, so result should be ready before first wait attempt finishes. | |
# context._MINUTE = .05 # "long" | |
# res2 = context.subproc_map(slow_identity_func, [(.01, 'b')]) # short | |
# # We shouldn't have seen any additional messages since, wait is now longer than func's sleep | |
# self.assertEquals(counting_log.counts[msg], loops) | |
# self.assertEquals(res2, ['b']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment