You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I stumbled upon a UnicodeDecodeError: 'ascii' codec can't decode byte... from the logger with certain values in SQLiteAckQueue + Python 2.7. After some investigation, it turns out that the problem lies with log.warning("Can't find item %s from unack cache", item) in combination with from __future__ import unicode_literals on Python 2.7.
Possible solutions:
Remove from __future__ import unicode_literals
Don't log item at all, but acknowledge the warning.
I am personally more in favor of the second approach as I don't think it is safe to be logging items in this situation. Maybe they contain sensitive information, can be very large, etc.
q = SQLiteAckQueue('testdata', auto_resume=True)
inflight_map = dict()
# Generate some messages.
q.put('test')
q.put(struct.pack("i", 255))
q.put('test2')
# Publish message over network. Store 'in flight' messages
for id in range(3):
foo = q.get()
inflight_map[id] = foo
# Some time passes and no acknowledgement. Republish them.
time.sleep(1)
q.resume_unack_tasks()
for id in range(4, 7):
foo = q.get()
inflight_map[id] = foo
# Some more time passes, and server confirms original messages. Acknowledge them.
# _unack_cache now does not contain the items, and triggers the log with the printing of item as a string.
time.sleep(1)
for id in range(3):
bar = inflight_map[id]
q.ack(bar)
The text was updated successfully, but these errors were encountered:
I stumbled upon a UnicodeDecodeError: 'ascii' codec can't decode byte... from the logger with certain values in SQLiteAckQueue + Python 2.7. After some investigation, it turns out that the problem lies with
log.warning("Can't find item %s from unack cache", item)
in combination withfrom __future__ import unicode_literals
on Python 2.7.Possible solutions:
from __future__ import unicode_literals
item
at all, but acknowledge the warning.I am personally more in favor of the second approach as I don't think it is safe to be logging items in this situation. Maybe they contain sensitive information, can be very large, etc.
The text was updated successfully, but these errors were encountered: