Skip to content

Instantly share code, notes, and snippets.

@brainstorm
Created March 4, 2011 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brainstorm/854585 to your computer and use it in GitHub Desktop.
Save brainstorm/854585 to your computer and use it in GitHub Desktop.
Celery tasks test
#!/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
@brainstorm
Copy link
Author

Tests on tasks:

from tasks import * lvm_snapshot_create.delay() print result.successful()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment