def encode(cls, item): """Convert an `item` to a string (Currently JSON) :param item: the item to encode :type item: dict """ return json.dumps(item)
def working_on(self, job): logger.debug('marking as working on') data = { 'queue': job._queue, 'run_at': str(int(time.mktime(datetime.datetime.now().timetuple()))), 'payload': job._payload } data = json.dumps(data) self.resq.redis["resque:worker:%s" % str(self)] = data logger.debug("worker:%s" % str(self)) logger.debug(self.resq.redis["resque:worker:%s" % str(self)])
def working_on(self, job): logger.debug("marking as working on") data = { "queue": job._queue, "run_at": str(int(time.mktime(datetime.datetime.now().timetuple()))), "payload": job._payload, } data = json.dumps(data) self.resq.redis["resque:worker:%s" % str(self)] = data logger.debug("worker:%s" % str(self)) logger.debug(self.resq.redis["resque:worker:%s" % str(self)])
def working_on(self, job): logger.debug('marking as working on') data = { 'queue': job._queue, 'run_at': now_iso(), 'payload': job._payload } data = json.dumps(data) self.resq.redis["resque:worker:%s" % str(self)] = data logger.debug("worker:%s" % str(self)) logger.debug(self.resq.redis["resque:worker:%s" % str(self)])
def working_on(self, job): setproctitle('pyres_minion:%s: working on job: %s' % (os.getppid(), job._payload)) self.logger.debug('marking as working on') data = { 'queue': job._queue, 'run_at': datetime.datetime.utcnow().isoformat() + "Z", 'payload': job._payload } data = json.dumps(data) self.resq.redis["resque:minion:%s" % str(self)] = data self.logger.debug("minion:%s" % str(self))
def working_on(self, job): setproctitle('pyres_minion:%s: working on job: %s' % (os.getppid(), job._payload)) self.logger.debug('marking as working on') data = { 'queue': job._queue, 'run_at': int(time.mktime(datetime.datetime.now().timetuple())), 'payload': job._payload } data = json.dumps(data) self.resq.redis["resque:minion:%s" % str(self)] = data self.logger.debug("minion:%s" % str(self))
def working_on(self, job): logger.debug('marking as working on') data = { 'queue': job._queue, 'run_at': datetime.datetime.utcnow().isoformat() + "Z", 'payload': job._payload } data = json.dumps(data) self.resq.redis[self.namespace + ":worker:%s" % str(self)] = data logger.debug("worker:%s" % str(self)) logger.debug(self.resq.redis[self.namespace + ":worker:%s" % str(self)])
def encode(cls, item): return json.dumps(item)
def test_encode_decode_date(self): dt = datetime(1972, 1, 22); encoded = json.dumps({'dt': dt}) decoded = json.loads(encoded) assert decoded['dt'] == dt
def test_dates_in_dict(self): dates = dict((i, datetime.now()) for i in range(50)) decoded = json.loads(json.dumps(dates)) for i, value in dates.items(): assert isinstance(i, int) assert isinstance(value, datetime)
def test_dates_in_lists(self): dates = [datetime.now() for i in range(50)] decoded = json.loads(json.dumps(dates)) for value in dates: assert isinstance(value, datetime)