<commit_before># python-redisjobqueue
Non-blocking job queue in Redis backend with distributed locking mechanism to prevent double work if multiple processes or threads are simultaneously dividing work load through one queue.

## How-To use

### Queue consumer -- get job from queue and lock it

Import the library to your project:
```python
from redisjobqueue import RedisJobQueue
# we also require time functions in this example later on
import time
```

Initialize queue and connection to Redis server:
```python
# redis server hostname and port number are optional arguments
#  and defaults are show below
queue = RedisJobQueue("my-queue", "redis-host", 6379)
```

Create a simple loop to wait for a job to appear in the queue:
```python
while True:
	# sleep a second before querying for a new job
	time.sleep(1)
	job = queue.get()
	if job:
		# lock_timeout is in milliseconds the amount of time after which lock
		#  automatically expires and the job is considered available for other
		#  consumers as well. Default is shown below.
		job_payload = job.get(lock_timeout=1000)
		print job_payload
		# release lock and remove data from queue
		job.completed()
```

### Queue publisher -- add work to queue

Import the library to your project:
```python
from redisjobqueue import RedisJobQueue
```

Initialize queue and connection to Redis server:
```python<commit_msg>fixed a typo in example<commit_after># python-redisjobqueue
Non-blocking job queue in Redis backend with distributed locking mechanism to prevent double work if multiple processes or threads are simultaneously dividing work load through one queue.

## How-To use

### Queue consumer -- get job from queue and lock it

Import the library to your project:
```python
from redisjobqueue import RedisJobQueue
# we also require time functions in this example later on
import time
```

Initialize queue and connection to Redis server:
```python
# redis server hostname and port number are optional arguments
#  and defaults are show below
queue = RedisJobQueue("my-queue", "redis-host", 6379)
```

Create a simple loop to wait for a job to appear in the queue:
```python
while True:
	# sleep a second before querying for a new job
	time.sleep(1)
	job = queue.get()
	if job:
		# lock_timeout is in milliseconds the amount of time after which lock
		#  automatically expires and the job is considered available for other
		#  consumers as well. Default is shown below.
		job_payload = job.get(lock_timeout=1000)
		print job_payload
		# release lock and remove data from queue
		job.complete()
```

### Queue publisher -- add work to queue

Import the library to your project:
```python
from redisjobqueue import RedisJobQueue
```

Initialize queue and connection to Redis server:
```python
{'fraction_non_alphanumeric': 0.06543075245365322, 'fraction_numerical': 0.006543075245365322, 'mean_word_length': 4.47117296222664, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6825740', 'n_tokens_mistral': 775, 'n_tokens_neox': 727, 'n_words': 373}