Python/thaw/freeze: Different references to same message

classic Classic list List threaded Threaded
2 messages Options
William Pettersson William Pettersson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Python/thaw/freeze: Different references to same message

Hey,

I've been trying to emulate something similar to what Ben Gamari shows
in https://notmuchmail.org/pipermail/notmuch/2011/003976.html and I ran
into an issue.

That script (which admittedly is from 6 years ago) freezes messages
before changing tags. But when changing tags, new searches are often
run, returning some of the same results. It seems any changes on these
"inner" messages are lost when the outer messages are thawed, and I'm
guessing this is because the "inner" and "outer" messages reference
different objects in memory which point to the same Xapian document.

I've attached a short script which demonstrates this, to test it you
need at least one message tagged with "this_is_my_test", but the script
is fairly simple.

Now If I'm correct in guessing the issue here, I can understand that
it's not the sort of thing that is fun to fix, so I'm more looking to
see if my understanding is right. In particular, I'm asking because
clearly 6 years ago Ben's scripts worked, so maybe I'm just not
understanding them/notmuch correctly.

If I am right, then I'll just leave out the freezing/thawing. As it
stands, I'm only adding ~5-10 emails at most each run (which is every 10
minutes) so performance when adding emails isn't (yet) an issue for me.

Will

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch

test_nm.py (667 bytes) Download Attachment
signature.asc (849 bytes) Download Attachment
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Python/thaw/freeze: Different references to same message

William Pettersson <[hidden email]> writes:

> That script (which admittedly is from 6 years ago) freezes messages
> before changing tags. But when changing tags, new searches are often
> run, returning some of the same results. It seems any changes on these
> "inner" messages are lost when the outer messages are thawed, and I'm
> guessing this is because the "inner" and "outer" messages reference
> different objects in memory which point to the same Xapian document.

That sounds likely to be the case. There's no attempt to synchronize
multiple in memory caches of the same xapian document.

> Now If I'm correct in guessing the issue here, I can understand that
> it's not the sort of thing that is fun to fix, so I'm more looking to
> see if my understanding is right. In particular, I'm asking because
> clearly 6 years ago Ben's scripts worked, so maybe I'm just not
> understanding them/notmuch correctly.
>
> If I am right, then I'll just leave out the freezing/thawing. As it
> stands, I'm only adding ~5-10 emails at most each run (which is every 10
> minutes) so performance when adding emails isn't (yet) an issue for me.

You might try begin_atomic / end_atomic instead. These nest properly by
design, although I'm not so confident about the performance impact
(they're not really focussed on performance).
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Loading...