From c07105e04e667342ce3b3a7a2441d4e037acfbfb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= <sybren@stuvel.eu>
Date: Fri, 29 Sep 2017 12:20:32 +0200
Subject: [PATCH] Renamed flush_for_shutdown() to flush_and_report()

It'll be called in non-shutdown situations too.
---
 flamenco_worker/upstream_update_queue.py | 10 +++++-----
 flamenco_worker/worker.py                |  2 +-
 tests/test_worker.py                     |  4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/flamenco_worker/upstream_update_queue.py b/flamenco_worker/upstream_update_queue.py
index 4db476b8..eed8b3d5 100644
--- a/flamenco_worker/upstream_update_queue.py
+++ b/flamenco_worker/upstream_update_queue.py
@@ -149,23 +149,23 @@ class TaskUpdateQueue:
 
         return queue_is_empty
 
-    async def flush_for_shutdown(self, *, loop: asyncio.AbstractEventLoop):
+    async def flush_and_report(self, *, loop: asyncio.AbstractEventLoop):
         """Flushes the queue, and just reports errors, doesn't wait nor retry."""
 
         import requests
 
-        self._log.info('flush_for_shutdown: trying one last push to get updates to Manager')
+        self._log.info('flush_and_report: trying one last push to get updates to Manager')
 
         try:
             await self.flush(loop=loop)
         except requests.ConnectionError:
-            self._log.warning('flush_for_shutdown: Unable to connect to Manager, '
+            self._log.warning('flush_and_report: Unable to connect to Manager, '
                               'some items are still queued.')
         except requests.HTTPError as ex:
-            self._log.warning('flush_for_shutdown: Manager did not accept our updates (%s),'
+            self._log.warning('flush_and_report: Manager did not accept our updates (%s),'
                               ' some items are still queued.', ex)
         except Exception:
-            self._log.exception('flush_for_shutdown: Unexpected exception, '
+            self._log.exception('flush_and_report: Unexpected exception, '
                                 'Some items are still queued.')
 
     async def flush_and_catch(self, *, loop: asyncio.AbstractEventLoop):
diff --git a/flamenco_worker/worker.py b/flamenco_worker/worker.py
index f8c46ac1..9fac48b0 100644
--- a/flamenco_worker/worker.py
+++ b/flamenco_worker/worker.py
@@ -279,7 +279,7 @@ class FlamencoWorker:
             self.loop.run_until_complete(self.push_to_manager())
 
         # Try to do a final push of queued updates to the Manager.
-        self.loop.run_until_complete(self.tuqueue.flush_for_shutdown(loop=self.loop))
+        self.loop.run_until_complete(self.tuqueue.flush_and_report(loop=self.loop))
 
         # Let the Manager know we're shutting down
         self._log.info('shutdown(): signing off at Manager')
diff --git a/tests/test_worker.py b/tests/test_worker.py
index e620ccee..1542696c 100644
--- a/tests/test_worker.py
+++ b/tests/test_worker.py
@@ -26,7 +26,7 @@ class AbstractFWorkerTest(AbstractWorkerTest):
 
         self.trunner = Mock(spec=TaskRunner)
         self.tuqueue = Mock(spec=TaskUpdateQueue)
-        self.tuqueue.flush_for_shutdown = CoroMock()
+        self.tuqueue.flush_and_report = CoroMock()
 
         self.trunner.execute = self.mock_task_execute
         self.trunner.abort_current_task = CoroMock()
@@ -407,7 +407,7 @@ class WorkerShutdownTest(AbstractWorkerTest):
 
         self.trunner = Mock(spec=TaskRunner)
         self.tuqueue = Mock(spec=TaskUpdateQueue)
-        self.tuqueue.flush_for_shutdown = CoroMock()
+        self.tuqueue.flush_and_report = CoroMock()
         self.trunner.abort_current_task = CoroMock()
 
         self.worker = FlamencoWorker(
-- 
GitLab