This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
JobtasticMixins
===============

## Package includes:

#### AVGTimeRedis class
The class that helps automate calculate an avarage time
for different kind tasks and saves result into Redis DB


## Install
Install from Github

```pip install https://github.com/abbasovalex/JobtasticMixins/archive/master.zip```


## Usage

1. You must will add the mixin class as first argument
2. You should set ```default_avg_time``` in the seconds
3. You must use ```self.update_progress()``` without arguments

```python
class YourTask(AVGTimeRedis, JobtasticTask):
default_avg_time = 60 # 1 minute

...

def calculate_result(self, ..., **kwargs):
...
```

```default_avg_time``` used when task still never calculated
It will be encompass arithmetical mean after task was executed.
Forecast accuracy depends from count executed tasks


### Example with AVGTimeRedis class

The class that helps automate calculate an avarage time for different kind
tasks and saves result into Redis DB

Let's take a look at the example task using with JobtasticMixins and
AVGTimeRedis class:

``` python
from time import sleep
from jobtastic import JobtasticTask
from jobtasticmixins import AVGTimeRedis


class LotsOfDivisionTask(AVGTimeRedis, JobtasticTask):
"""
Division is hard. Make Celery do it a bunch.
"""
significant_kwargs = [
('numerators', str),
('denominators', str),
]
herd_avoidance_timeout = 60
cache_duration = 0
# optional variable was added. by default is 30 seconds
default_avg_time = 90

def calculate_result(self, numerators, denominators, **kwargs):
results = []
for count, divisors in enumerate(zip(numerators, denominators)):
numerator, denominator = divisors
results.append(numerator / denominator)
# it will be auto calculated
self.update_progress()
sleep(0.1)

# set finish=True for avoid trouble
self.update_progress(finish=True)
return results

```

Under the hood:

1. AVGTimeRedis gets settings.BROKER_URL and connects to Redis
2. It counts the tasks and the workers and uses to calculating

More details you can see into [source](https://github.com/abbasovalex/JobtasticMixins/blob/master/jobtasticmixins/mixins.py)
Release History

Release History

0.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
jobtastic-mixins-0.1.tar.gz (5.2 kB) Copy SHA256 Checksum SHA256 Source Mar 20, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting