Created
March 4, 2011 13:04
-
-
Save brainstorm/854585 to your computer and use it in GitHub Desktop.
Celery tasks test
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
#!/usr/bin/env python | |
import subprocess | |
from celery.task import task | |
# Task overlapping: | |
# lvm_create --> archive --> transfer(delayed?) --> (verify) --> lvm_destroy | |
# basecalling --> fastq transfer (8h ?) | |
# Without LVM: | |
# archive --> transfer --> verify | |
# --> basecalling --> fastq transfer | |
# Solution: | |
# http://www.loose-bits.com/2010/10/distributed-task-locking-in-celery.html#more | |
@task | |
def lvm_snapshot_create(dataset): | |
print "Creating LVM snapshot for dataset %s" | |
# cl = "lvm create -LXXXG -s dataset_backup /dev/mapper" | |
# cl += "mount /dev/mapper/" + dataset | |
# subprocess.check_call(cl) | |
@task | |
def lvm_snapshot_destroy(dataset): | |
print "Destroying LVM snapshot for dataset %s" | |
# cl = "lvm remove /dev/mapper/backups" | |
# cl += "umount /dev/mapper/" + dataset | |
## XXX check that the dataset has sent and validated successfully | |
# subprocess.check_call(cl) | |
@task | |
def archive_create(dataset): | |
print "Archiving dataset %s" | |
# cl = "tarit.sh" + dataset | |
#subprocess.check_call("echo TAR DONE") | |
@task | |
def transfer(archive) | |
""" | |
Transfers backup of the current dataset | |
""" | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tests on tasks:
from tasks import * lvm_snapshot_create.delay() print result.successful()