Stream-Framework icon indicating copy to clipboard operation
Stream-Framework copied to clipboard

enforcing pickle to use copy of dict while serializing extra context of the notification

Open jumpjam opened this issue 12 years ago • 5 comments

This fixes a type of notification extra context pickling in our case (remove was failing as key not found).

Example that satisfies the condition: import pickle x = {'order_number': 'X', 'deal_url': 'J'}

pickle.dumps(x) pickle.dumps(pickle.loads(pickle.dumps(x))) pickle.dumps(pickle.loads(pickle.dumps(pickle.loads(pickle.dumps(x)))))

Where 1 and 3 are same but second is different.

jumpjam avatar Apr 15 '14 04:04 jumpjam

Which feed class and with which storage backend did you run into this problem?

Thanks for contributing, we really appreciate it.

tschellenbach avatar Apr 15 '14 08:04 tschellenbach

Part of the problem seems to be that: https://github.com/tschellenbach/Feedly/blob/master/feedly/storage/redis/timeline_storage.py#L91

Removes by value instead of by key. Not sure why this is.

tschellenbach avatar Apr 15 '14 08:04 tschellenbach

Think we could easily use http://redis.io/commands/zremrangebyscore over there

tschellenbach avatar Apr 15 '14 08:04 tschellenbach

Hi,

I have used current redis version with following notification class:

class NotificationFeedly(RedisNotificationFeed): key_format = 'custom_feed:notification:%(user_id)s'

Debugged down to zrem which returned 0 as value is not found.

I also agree using rembyscore which might be a reliable and faster solution. We will keep fork and switch back to main rep in case any changes on serialization or zrem.

Thank you

jumpjam avatar Apr 15 '14 15:04 jumpjam

Solution #1191a64 doesnt resolve a case with nested dicts. Recursive algorithm will.

Atorich avatar Nov 21 '15 10:11 Atorich