Skip to content

Commit

Permalink
Pass download lock between xdist workers
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoRoth committed Apr 18, 2018
1 parent 00b8314 commit 60fe57a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions oggm/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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())

0 comments on commit 60fe57a

Please sign in to comment.