Skip to content

Commit

Permalink
Let gearmand handle job uniques and don't stuff the data into the uni…
Browse files Browse the repository at this point in the history
…que on '-'
  • Loading branch information
Eskil Olsen authored and yannk committed Aug 30, 2013
1 parent b563ff0 commit d8dc9e9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions gearman/client.py
Expand Up @@ -13,7 +13,7 @@

gearman_logger = logging.getLogger(__name__)

# This number must be <= GEARMAN_UNIQUE_SIZE in gearman/libgearman/constants.h
# This number must be <= GEARMAN_UNIQUE_SIZE in gearman/libgearman/constants.h
RANDOM_UNIQUE_BYTES = 16

class GearmanClient(GearmanConnectionManager):
Expand Down Expand Up @@ -167,9 +167,7 @@ def _create_request_from_dictionary(self, job_info, background=False, max_retrie
"""Takes a dictionary with fields {'task': task, 'unique': unique, 'data': data, 'priority': priority, 'background': background}"""
# Make sure we have a unique identifier for ALL our tasks
job_unique = job_info.get('unique')
if job_unique == '-':
job_unique = job_info['data']
elif not job_unique:
if not job_unique:
job_unique = os.urandom(self.random_unique_bytes).encode('hex')

current_job = self.job_class(connection=None, handle=None, task=job_info['task'], unique=job_unique, data=job_info['data'])
Expand Down

0 comments on commit d8dc9e9

Please sign in to comment.