From 60fe57a28bb03a0bd2be49cc6c8842cf0a698f27 Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler Date: Wed, 18 Apr 2018 15:05:40 +0200 Subject: [PATCH] Pass download lock between xdist workers --- oggm/tests/conftest.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 oggm/tests/conftest.py diff --git a/oggm/tests/conftest.py b/oggm/tests/conftest.py new file mode 100644 index 000000000..c3d5e9486 --- /dev/null +++ b/oggm/tests/conftest.py @@ -0,0 +1,22 @@ +import pytest +import multiprocessing as mp +from oggm import utils +from random import randint + +global_lock = mp.Manager().Lock() + +class OggmMpLockPlugin(): + def pytest_configure(config): + if hasattr(config, 'slaveinput'): + print("In Slave: %s" % config.workerinput['shared_lock']) + else: + config.shared_lock = randint(0, 100) + print("In Master: %s" % config.shared_lock) + + def pytest_configure_node(node): + node.workerinput['shared_lock'] = node.config.shared_lock + +def pytest_configure(config): + if config.pluginmanager.hasplugin('xdist'): + config.pluginmanager.register(OggmMpLockPlugin()) +