/usr/lib/python2.7/dist-packages/pgq/event.py is in skytools 2.1.13-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | """PgQ event container.
"""
__all__ = ['EV_RETRY', 'EV_DONE', 'EV_FAILED', 'Event']
# Event status codes
EV_RETRY = 0
EV_DONE = 1
EV_FAILED = 2
_fldmap = {
'ev_id': 'ev_id',
'ev_txid': 'ev_txid',
'ev_time': 'ev_time',
'ev_type': 'ev_type',
'ev_data': 'ev_data',
'ev_retry': 'ev_retry',
'ev_extra1': 'ev_extra1',
'ev_extra2': 'ev_extra2',
'ev_extra3': 'ev_extra3',
'ev_extra4': 'ev_extra4',
'id': 'ev_id',
'txid': 'ev_txid',
'time': 'ev_time',
'type': 'ev_type',
'data': 'ev_data',
'retry': 'ev_retry',
'extra1': 'ev_extra1',
'extra2': 'ev_extra2',
'extra3': 'ev_extra3',
'extra4': 'ev_extra4',
}
class Event(object):
"""Event data for consumers.
Consumer is supposed to tag them after processing.
If not, events will stay in retry queue.
"""
def __init__(self, queue_name, row):
self._event_row = row
self.status = EV_RETRY
self.retry_time = 60
self.fail_reason = "Buggy consumer"
self.queue_name = queue_name
def __getattr__(self, key):
return self._event_row[_fldmap[key]]
def tag_done(self):
self.status = EV_DONE
def tag_retry(self, retry_time = 60):
self.status = EV_RETRY
self.retry_time = retry_time
def tag_failed(self, reason):
self.status = EV_FAILED
self.fail_reason = reason
|