Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
No build reason found for SLE-Manager-Tools:x86_64
systemsmanagement:Uyuni:Master:Ubuntu1804-Uyuni-Client-Tools
venv-salt-minion
changed-imports-to-vendored-tornado.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File changed-imports-to-vendored-tornado.patch of Package venv-salt-minion
From 5db9ccdb4f557cdbff670b18c45e55124e29c57c Mon Sep 17 00:00:00 2001 From: Jochen Breuer <jbreuer@suse.de> Date: Tue, 10 Mar 2020 14:02:17 +0100 Subject: [PATCH] Changed imports to vendored Tornado --- salt/cli/batch_async.py | 25 ++++++++++++----------- salt/master.py | 2 +- tests/unit/cli/test_batch_async.py | 32 +++++++++++++++--------------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/salt/cli/batch_async.py b/salt/cli/batch_async.py index 3dc04826d1..09aa85258b 100644 --- a/salt/cli/batch_async.py +++ b/salt/cli/batch_async.py @@ -8,6 +8,7 @@ import gc import logging import salt.client +import salt.ext.tornado import tornado from salt.cli.batch import batch_get_eauth, batch_get_opts, get_bnum @@ -46,7 +47,7 @@ class BatchAsync: """ def __init__(self, parent_opts, jid_gen, clear_load): - ioloop = tornado.ioloop.IOLoop.current() + ioloop = salt.ext.tornado.ioloop.IOLoop.current() self.local = salt.client.get_local_client( parent_opts["conf_file"], io_loop=ioloop ) @@ -161,7 +162,7 @@ class BatchAsync: self.find_job_returned = self.find_job_returned.difference(running) self.event.io_loop.spawn_callback(self.find_job, running) - @tornado.gen.coroutine + @salt.ext.tornado.gen.coroutine def find_job(self, minions): if self.event: not_done = minions.difference(self.done_minions).difference( @@ -182,7 +183,7 @@ class BatchAsync: jid=jid, **self.eauth ) - yield tornado.gen.sleep(self.opts["gather_job_timeout"]) + yield salt.ext.tornado.gen.sleep(self.opts["gather_job_timeout"]) if self.event: self.event.io_loop.spawn_callback( self.check_find_job, not_done, jid @@ -195,7 +196,7 @@ class BatchAsync: ) self.close_safe() - @tornado.gen.coroutine + @salt.ext.tornado.gen.coroutine def start(self): if self.event: self.__set_event_handler() @@ -213,13 +214,13 @@ class BatchAsync: ) self.targeted_minions = set(ping_return["minions"]) # start batching even if not all minions respond to ping - yield tornado.gen.sleep( + yield salt.ext.tornado.gen.sleep( self.batch_presence_ping_timeout or self.opts["gather_job_timeout"] ) if self.event: self.event.io_loop.spawn_callback(self.start_batch) - @tornado.gen.coroutine + @salt.ext.tornado.gen.coroutine def start_batch(self): if not self.initialized: self.batch_size = get_bnum(self.opts, self.minions, True) @@ -235,7 +236,7 @@ class BatchAsync: if self.event: self.event.io_loop.spawn_callback(self.run_next) - @tornado.gen.coroutine + @salt.ext.tornado.gen.coroutine def end_batch(self): left = self.minions.symmetric_difference( self.done_minions.union(self.timedout_minions) @@ -253,7 +254,7 @@ class BatchAsync: # release to the IOLoop to allow the event to be published # before closing batch async execution - yield tornado.gen.sleep(1) + yield salt.ext.tornado.gen.sleep(1) self.close_safe() def close_safe(self): @@ -266,16 +267,16 @@ class BatchAsync: del self gc.collect() - @tornado.gen.coroutine + @salt.ext.tornado.gen.coroutine def schedule_next(self): if not self.scheduled: self.scheduled = True # call later so that we maybe gather more returns - yield tornado.gen.sleep(self.batch_delay) + yield salt.ext.tornado.gen.sleep(self.batch_delay) if self.event: self.event.io_loop.spawn_callback(self.run_next) - @tornado.gen.coroutine + @salt.ext.tornado.gen.coroutine def run_next(self): self.scheduled = False next_batch = self._get_next() @@ -294,7 +295,7 @@ class BatchAsync: metadata=self.metadata, ) - yield tornado.gen.sleep(self.opts["timeout"]) + yield salt.ext.tornado.gen.sleep(self.opts["timeout"]) # The batch can be done already at this point, which means no self.event if self.event: diff --git a/salt/master.py b/salt/master.py index 7a99af357a..ab85c7f5c6 100644 --- a/salt/master.py +++ b/salt/master.py @@ -2237,7 +2237,7 @@ class ClearFuncs(TransportMethods): functools.partial(self._prep_jid, clear_load, {}), batch_load, ) - ioloop = tornado.ioloop.IOLoop.current() + ioloop = salt.ext.tornado.ioloop.IOLoop.current() ioloop.add_callback(batch.start) return { diff --git a/tests/unit/cli/test_batch_async.py b/tests/unit/cli/test_batch_async.py index dcee9a87bd..82a712b15b 100644 --- a/tests/unit/cli/test_batch_async.py +++ b/tests/unit/cli/test_batch_async.py @@ -1,8 +1,8 @@ -import tornado +import salt.ext.tornado from salt.cli.batch_async import BatchAsync +from salt.ext.tornado.testing import AsyncTestCase from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch from tests.support.unit import TestCase, skipIf -from tornado.testing import AsyncTestCase @skipIf(NO_MOCK, NO_MOCK_REASON) @@ -52,10 +52,10 @@ class AsyncBatchTestCase(AsyncTestCase, TestCase): self.batch.start_batch() self.assertEqual(self.batch.batch_size, 2) - @tornado.testing.gen_test + @salt.ext.tornado.testing.gen_test def test_batch_start_on_batch_presence_ping_timeout(self): self.batch.event = MagicMock() - future = tornado.gen.Future() + future = salt.ext.tornado.gen.Future() future.set_result({"minions": ["foo", "bar"]}) self.batch.local.run_job_async.return_value = future ret = self.batch.start() @@ -71,10 +71,10 @@ class AsyncBatchTestCase(AsyncTestCase, TestCase): # assert targeted_minions == all minions matched by tgt self.assertEqual(self.batch.targeted_minions, {"foo", "bar"}) - @tornado.testing.gen_test + @salt.ext.tornado.testing.gen_test def test_batch_start_on_gather_job_timeout(self): self.batch.event = MagicMock() - future = tornado.gen.Future() + future = salt.ext.tornado.gen.Future() future.set_result({"minions": ["foo", "bar"]}) self.batch.local.run_job_async.return_value = future self.batch.batch_presence_ping_timeout = None @@ -103,7 +103,7 @@ class AsyncBatchTestCase(AsyncTestCase, TestCase): ), ) - @tornado.testing.gen_test + @salt.ext.tornado.testing.gen_test def test_start_batch_calls_next(self): self.batch.run_next = MagicMock(return_value=MagicMock()) self.batch.event = MagicMock() @@ -160,14 +160,14 @@ class AsyncBatchTestCase(AsyncTestCase, TestCase): self.assertEqual(len(event.unsubscribe.mock_calls), 2) self.assertEqual(len(event.remove_event_handler.mock_calls), 1) - @tornado.testing.gen_test + @salt.ext.tornado.testing.gen_test def test_batch_next(self): self.batch.event = MagicMock() self.batch.opts["fun"] = "my.fun" self.batch.opts["arg"] = [] self.batch._get_next = MagicMock(return_value={"foo", "bar"}) self.batch.batch_size = 2 - future = tornado.gen.Future() + future = salt.ext.tornado.gen.Future() future.set_result({"minions": ["foo", "bar"]}) self.batch.local.run_job_async.return_value = future self.batch.run_next() @@ -290,38 +290,38 @@ class AsyncBatchTestCase(AsyncTestCase, TestCase): self.batch._BatchAsync__event_handler(MagicMock()) self.assertEqual(self.batch.find_job_returned, {"foo"}) - @tornado.testing.gen_test + @salt.ext.tornado.testing.gen_test def test_batch_run_next_end_batch_when_no_next(self): self.batch.end_batch = MagicMock() self.batch._get_next = MagicMock(return_value={}) self.batch.run_next() self.assertEqual(len(self.batch.end_batch.mock_calls), 1) - @tornado.testing.gen_test + @salt.ext.tornado.testing.gen_test def test_batch_find_job(self): self.batch.event = MagicMock() - future = tornado.gen.Future() + future = salt.ext.tornado.gen.Future() future.set_result({}) self.batch.local.run_job_async.return_value = future self.batch.minions = {"foo", "bar"} self.batch.jid_gen = MagicMock(return_value="1234") - tornado.gen.sleep = MagicMock(return_value=future) + salt.ext.tornado.gen.sleep = MagicMock(return_value=future) self.batch.find_job({"foo", "bar"}) self.assertEqual( self.batch.event.io_loop.spawn_callback.call_args[0], (self.batch.check_find_job, {"foo", "bar"}, "1234"), ) - @tornado.testing.gen_test + @salt.ext.tornado.testing.gen_test def test_batch_find_job_with_done_minions(self): self.batch.done_minions = {"bar"} self.batch.event = MagicMock() - future = tornado.gen.Future() + future = salt.ext.tornado.gen.Future() future.set_result({}) self.batch.local.run_job_async.return_value = future self.batch.minions = {"foo", "bar"} self.batch.jid_gen = MagicMock(return_value="1234") - tornado.gen.sleep = MagicMock(return_value=future) + salt.ext.tornado.gen.sleep = MagicMock(return_value=future) self.batch.find_job({"foo", "bar"}) self.assertEqual( self.batch.event.io_loop.spawn_callback.call_args[0], -- 2.29.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor