コード例 #1
0
    def event_from_message(self,
                           body,
                           localize=True,
                           now=time.time,
                           tzfields=_TZGETTER,
                           adjust_timestamp=adjust_timestamp,
                           CLIENT_CLOCK_SKEW=CLIENT_CLOCK_SKEW):
        type = body['type']
        if type == 'task-sent':
            # clients never sync so cannot use their clock value
            _c = body['clock'] = (self.clock.value or 1) + CLIENT_CLOCK_SKEW
            self.adjust_clock(_c)
        else:
            try:
                clock = body['clock']
            except KeyError:
                body['clock'] = self.forward_clock()
            else:
                self.adjust_clock(clock)

        if localize:
            try:
                offset, timestamp = tzfields(body)
            except KeyError:
                pass
            else:
                body['timestamp'] = adjust_timestamp(timestamp, offset)
        body['local_received'] = now()
        return type, body
コード例 #2
0
ファイル: __init__.py プロジェクト: LeZenda/celery
    def event_from_message(self, body, localize=True,
                           now=time.time, tzfields=_TZGETTER,
                           adjust_timestamp=adjust_timestamp,
                           CLIENT_CLOCK_SKEW=CLIENT_CLOCK_SKEW):
        type = body['type']
        if type == 'task-sent':
            # clients never sync so cannot use their clock value
            _c = body['clock'] = (self.clock.value or 1) + CLIENT_CLOCK_SKEW
            self.adjust_clock(_c)
        else:
            try:
                clock = body['clock']
            except KeyError:
                body['clock'] = self.forward_clock()
            else:
                self.adjust_clock(clock)

        if localize:
            try:
                offset, timestamp = tzfields(body)
            except KeyError:
                pass
            else:
                body['timestamp'] = adjust_timestamp(timestamp, offset)
        body['local_received'] = now()
        return type, body
コード例 #3
0
ファイル: __init__.py プロジェクト: dzikri/celery
    def event_from_message(self, body, localize=True, now=time.time):
        type = body.get('type', '').lower()
        clock = body.get('clock')
        if clock:
            self.adjust_clock(clock)

        if localize:
            try:
                offset, timestamp = _TZGETTER(body)
            except KeyError:
                pass
            else:
                body['timestamp'] = adjust_timestamp(timestamp, offset)
        return type, Event(type, body, local_received=now())
コード例 #4
0
    def event_from_message(self, body, localize=True, now=time.time):
        type = body.get('type', '').lower()
        clock = body.get('clock')
        if clock:
            self.adjust_clock(clock)

        if localize:
            try:
                offset, timestamp = _TZGETTER(body)
            except KeyError:
                pass
            else:
                body['timestamp'] = adjust_timestamp(timestamp, offset)
        return type, Event(type, body, local_received=now())
コード例 #5
0
ファイル: __init__.py プロジェクト: nonoDevil/celery
    def event_from_message(
        self, body, localize=True, now=monotonic, tzfields=_TZGETTER, adjust_timestamp=adjust_timestamp
    ):
        type = body.get("type", "").lower()
        clock = body.get("clock")
        if clock:
            self.adjust_clock(clock)

        if localize:
            try:
                offset, timestamp = tzfields(body)
            except KeyError:
                pass
            else:
                body["timestamp"] = adjust_timestamp(timestamp, offset)
        return type, Event(type, body, local_received=now())
コード例 #6
0
ファイル: __init__.py プロジェクト: ionelmc/celery
    def event_from_message(
        self, body, localize=True, now=time.time, tzfields=_TZGETTER, adjust_timestamp=adjust_timestamp
    ):
        type = body["type"]
        if type == "task-sent":
            # clients never sync so cannot use their clock value
            body["clock"] = self.forward_clock()
        else:
            try:
                clock = body["clock"]
            except KeyError:
                body["clock"] = self.forward_clock()
            else:
                self.adjust_clock(clock)

        if localize:
            try:
                offset, timestamp = tzfields(body)
            except KeyError:
                pass
            else:
                body["timestamp"] = adjust_timestamp(timestamp, offset)
        body["local_received"] = now()
        return type, body