data.py 526 B

1234567891011121314151617181920212223
  1. # -*- coding: utf-8 -*-
  2. from __future__ import absolute_import
  3. from celery.utils.debug import humanbytes
  4. class Data(object):
  5. def __init__(self, label, data):
  6. self.label = label
  7. self.data = data
  8. def __str__(self):
  9. return '<Data: {0} {1}>'.format(
  10. self.label, humanbytes(len(self.data)),
  11. )
  12. def __reduce__(self):
  13. return Data, (self.label, self.data)
  14. __unicode__ = __repr__ = __str__
  15. BIG = Data("BIG", 'x' * 2 ** 20 * 8)
  16. SMALL = Data("SMALL", 'e' * 1024)