I am running this code:
c = """
match(r:XX)
optional match(r)-[]-(m) with count(m) as mc, r match(x)
return count(x) as all, r, mc
"""
(snip!)
while(True):
tx = remote_graph.cypher.begin()
res = remote_graph.cypher.execute(c)
tx.rollback()
time.sleep(15)
(snip!)
I know for a fact the XX node's properties are changing every second - there a daemon running. However, when I run this, I always get the same values back in res
but for r
only - all
is changing. The query isn't changing. I wonder if py2neo is noticing this and not executing the query, but is returning me a cached copy? If so, how do I stop this from happening?
EDIT - more info - I ran the above from within ipython.
Interesting enough, py2neo 'remembers' the node when you return the node:
But when you return individual properties, they will always be updated:
For your query that means you have to run
my_node.pull()
when you return the same node twice in awhile
loop:You can also move everything besides the
pull()
out of the loop:Here is a minimal example describing the behaviour: http://paste.ubuntu.com/14015568/
I'm not really sure why py2neo does not return updated node data when you run a new query.
What do you mean when you say the node's attributes? Do you mean properties? Or are relationships added/removed as well?
What do you expect to get back in
r
? Judging from the query, unless the daemon you mention is adding/removing the:XX
label to/from nodes, it'll return exactly the same nodes always.