From cb6fa7e8932ff62ef6c1860ec334b880a7861268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= <sybren@stuvel.eu> Date: Thu, 15 Nov 2018 11:42:53 +0100 Subject: [PATCH] =?UTF-8?q?Upgraded=20from=20Python=203.5=20=E2=86=92=203.?= =?UTF-8?q?7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + Pipfile | 4 ++-- Pipfile.lock | 10 +++++----- flamenco_worker/upstream_update_queue.py | 2 +- flamenco_worker/worker.py | 14 +++++++------- setup.cfg | 2 +- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6240e97..ac84d1fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ changed functionality, fixed bugs). already is such a file with an alive PID. - Log lines produced by subprocesses are now prefixed with 'PID=nnn'. - Moved from pip-installing requirements.txt to Pipenv. +- Upgraded Python from 3.5 to 3.7 ## Version 2.1.0 (2018-01-04) diff --git a/Pipfile b/Pipfile index 531fd7ca..8742be27 100644 --- a/Pipfile +++ b/Pipfile @@ -9,7 +9,7 @@ requests = "*" psutil = "*" [dev-packages] -pytest = "*" +pytest = "<4" # pytest-cov uses deprecated function (removed in pytest 4) when using --no-cov pytest-cov = "*" wheel = "*" pyinstaller = "*" @@ -18,4 +18,4 @@ pathlib2 = {version = "*", markers="python_version < '3.6'"} mypy = "*" [requires] -python_version = "3.5" +python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock index cbb38b14..39a4591c 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,11 +1,11 @@ { "_meta": { "hash": { - "sha256": "e426596954522d58f3248f5f4651067486da5aff3799d5568f8843289fdc4de8" + "sha256": "b0736d28b87f6c3f3541d2bab2740817ad8f51db7f8e92ce7bd6068ab2ac32c8" }, "pipfile-spec": 6, "requires": { - "python_version": "3.5" + "python_version": "3.7" }, "sources": [ { @@ -289,11 +289,11 @@ }, "pytest": { "hashes": [ - "sha256:488c842647bbeb350029da10325cb40af0a9c7a2fdda45aeb1dda75b60048ffb", - "sha256:c055690dfefa744992f563e8c3a654089a6aa5b8092dded9b6fafbd70b2e45a7" + "sha256:3f193df1cfe1d1609d4c583838bea3d532b18d6160fd3f55c9447fdca30848ec", + "sha256:e246cf173c01169b9617fc07264b7b1316e78d7a650055235d6d897bc80d9660" ], "index": "pypi", - "version": "==4.0.0" + "version": "==3.10.1" }, "pytest-cov": { "hashes": [ diff --git a/flamenco_worker/upstream_update_queue.py b/flamenco_worker/upstream_update_queue.py index e33e3ea5..280be06a 100644 --- a/flamenco_worker/upstream_update_queue.py +++ b/flamenco_worker/upstream_update_queue.py @@ -134,7 +134,7 @@ class TaskUpdateQueue: Returns True iff the queue was empty, even before flushing. """ - with (await self._queue_lock): + async with self._queue_lock: queue_is_empty = True queue_size_before = self.queue_size() handled = 0 diff --git a/flamenco_worker/worker.py b/flamenco_worker/worker.py index c3b87dfd..4b60c7eb 100644 --- a/flamenco_worker/worker.py +++ b/flamenco_worker/worker.py @@ -49,10 +49,10 @@ class WorkerState(enum.Enum): SHUTTING_DOWN = 'shutting-down' -@attr.s() +@attr.s(auto_attribs=True) class PreTaskCheckParams: - pre_task_check_write = attr.ib(validator=attr.validators.instance_of(tuple), factory=tuple) - pre_task_check_read = attr.ib(validator=attr.validators.instance_of(tuple), factory=tuple) + pre_task_check_write: typing.List[str] = [] + pre_task_check_read: typing.List[str] = [] class PreTaskCheckFailed(PermissionError): @@ -381,7 +381,7 @@ class FlamencoWorker: # Prevent outgoing queue overflowing by waiting until it's below the # threshold before starting another task. # TODO(sybren): introduce another worker state for this, and handle there. - with (await self._queue_lock): + async with self._queue_lock: queue_size = self.tuqueue.queue_size() if queue_size > QUEUE_SIZE_THRESHOLD: self._log.info('Task Update Queue size too large (%d > %d), waiting until it shrinks.', @@ -474,7 +474,7 @@ class FlamencoWorker: # Such a failure will always result in a failed task, even when # self.failures_are_acceptable = True; only expected failures are # acceptable then. - with (await self._queue_lock): + async with self._queue_lock: self._queued_log_entries.append(traceback.format_exc()) await self.register_task_update( task_status='failed', @@ -533,7 +533,7 @@ class FlamencoWorker: if self._push_act_to_manager is not None: self._push_act_to_manager.cancel() - with (await self._queue_lock): + async with self._queue_lock: if self._queued_log_entries: payload['log'] = '\n'.join(self._queued_log_entries) self._queued_log_entries.clear() @@ -596,7 +596,7 @@ class FlamencoWorker: log_entry %= fmt_args now = datetime.datetime.now(tz.tzutc()).isoformat() - with (await self._queue_lock): + async with self._queue_lock: self._queued_log_entries.append('%s: %s' % (now, log_entry)) queue_size = len(self._queued_log_entries) diff --git a/setup.cfg b/setup.cfg index 8a274d06..dde7961b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,7 @@ addopts = -v --cov flamenco_worker --cov-report term-missing --ignore node_modules [mypy] -python_version = 3.5 +python_version = 3.7 warn_unused_ignores = True ignore_missing_imports = True follow_imports = skip -- GitLab