-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
826 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,3 +74,4 @@ dist/ | |
*.egg-info/ | ||
|
||
*ipynb_checkpoints* | ||
locking_tests/test.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,47 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import os | ||
|
||
from argparse import ArgumentParser | ||
from random import random | ||
from time import sleep | ||
|
||
from yacman import YacAttMap | ||
from yacman import FutureYAMLConfigManager as YAMLConfigManager | ||
from yacman import write_lock | ||
|
||
import logging | ||
|
||
_LOGGER = logging.getLogger() # root logger | ||
stream = logging.StreamHandler(sys.stdout) | ||
fmt = logging.Formatter( | ||
"%(levelname)s %(asctime)s | %(name)s:%(module)s:%(lineno)d > %(message)s " | ||
) | ||
stream.setFormatter(fmt) | ||
_LOGGER.setLevel(os.environ.get("LOGLEVEL", "DEBUG")) | ||
_LOGGER.addHandler(stream) | ||
|
||
|
||
parser = ArgumentParser(description="Test script") | ||
|
||
parser.add_argument("-p", "--path", help="path to the test file", required=True) | ||
parser.add_argument("-i", "--id", help="process id", required=True) | ||
parser.add_argument("-w", "--wait", help="max wait time", type=int, required=True) | ||
args = parser.parse_args() | ||
yam = YacAttMap(filepath=args.path, wait_max=args.wait) | ||
with yam as y: | ||
sleep(random()) | ||
y.update({args.id: 1}) | ||
ym = YAMLConfigManager.from_yaml_file(args.path, wait_max=args.wait) | ||
|
||
with write_lock(ym) as locked_y: | ||
locked_y.rebase() | ||
random_wait_time = random() | ||
_LOGGER.debug( | ||
f"Sleeping for {random_wait_time} to simulate process {args.id} updating the file" | ||
) | ||
sleep(random_wait_time) | ||
locked_y.update({args.id: 1}) | ||
_LOGGER.debug(f"Writing to file for process {args.id}.") | ||
locked_y.write() | ||
|
||
|
||
sys.exit(0) | ||
raise SystemExit | ||
# sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
from argparse import ArgumentParser | ||
from random import random | ||
from time import sleep | ||
|
||
from yacman import YacAttMap | ||
|
||
parser = ArgumentParser(description="Test script") | ||
|
||
parser.add_argument("-p", "--path", help="path to the test file", required=True) | ||
parser.add_argument("-i", "--id", help="process id", required=True) | ||
parser.add_argument("-w", "--wait", help="max wait time", type=int, required=True) | ||
args = parser.parse_args() | ||
yam = YacAttMap(filepath=args.path, wait_max=args.wait) | ||
with yam as y: | ||
sleep(random()) | ||
y.update({args.id: 1}) | ||
|
||
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
jsonschema>=3.2.0 | ||
pyyaml>=5.0 | ||
ubiquerg>=0.6.3 | ||
ubiquerg>=0.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
""" Test suite shared objects and setup """ | ||
|
||
import os | ||
from glob import glob | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.