summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Pollard <tom.pollard@codethink.co.uk>2019-11-25 14:29:31 +0000
committerTom Pollard <tom.pollard@codethink.co.uk>2019-11-27 11:54:58 +0000
commit577d29b1ea9913a71206ef27782a8d0b760144b0 (patch)
tree6f0d3d06185585d5bb42140e8a3057728953420d
parent0089029945246b644b3113827db02fae8943d79f (diff)
downloadbuildstream-tpollard/temp.tar.gz
Reset event loop in scheduler if subprocessed & pytest timeouttpollard/temp
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--src/buildstream/_scheduler/scheduler.py4
-rw-r--r--src/buildstream/_stream.py1
3 files changed, 6 insertions, 1 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f393be56b..f3f803691 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -16,7 +16,7 @@ stages:
variables:
PYTEST_ADDOPTS: "--color=yes"
INTEGRATION_CACHE: "${CI_PROJECT_DIR}/cache/integration-cache"
- PYTEST_ARGS: "--color=yes --integration -n 2"
+ PYTEST_ARGS: "--color=yes --timeout=1 --integration -n 2"
TEST_COMMAND: "tox -- ${PYTEST_ARGS}"
EXTERNAL_TESTS_COMMAND: "tox -e py{35,36,37}-external -- ${PYTEST_ARGS}"
COVERAGE_PREFIX: "${CI_JOB_NAME}."
diff --git a/src/buildstream/_scheduler/scheduler.py b/src/buildstream/_scheduler/scheduler.py
index 886867dfe..6ee20bd81 100644
--- a/src/buildstream/_scheduler/scheduler.py
+++ b/src/buildstream/_scheduler/scheduler.py
@@ -235,6 +235,10 @@ class Scheduler:
failed = any(queue.any_failed_elements() for queue in self.queues)
self.loop = None
+ # Unset the global event loop, if subprocessed
+ if subprocessed:
+ asyncio.set_event_loop_policy(None)
+
# Notify that the loop has been reset
self._notify_front(Notification(NotificationType.RUNNING))
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index e62c2550f..9fdbcd94f 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -172,6 +172,7 @@ class Stream:
# We can now launch another async
self.loop = asyncio.new_event_loop()
+ asyncio.set_event_loop(self.loop)
self._connect_signals()
self._start_listening()
self.loop.set_exception_handler(self._handle_exception)