<div dir="ltr"><div><div>Dear twisted users,<br><br></div>I have discovered the cause of this strange behavior. This is a good one.<br><br>The object exposed to you as a client when you receive a RemoteCache is not the same object which is passed in as "self" to observe_* methods. In the source code, there is a pair of objects created when a RemoteCache is received. One of them is given to the client, and the other remains in the shadows of pb for reasons I don't yet understand. For some reason remoteMessageReceived delegates observe_* methods to the object which is not the one given to the client. This means that normal methods and observe_* methods get different self arguments.<br>
<br>The authors seemed to try to cover this up by forcing the two objects to share the same __dict__ and __class__. Of course this does not give the objects the same id, which was the source of my problem.<br><br></div>I have reported this issue here: <a href="https://twistedmatrix.com/trac/ticket/7274">https://twistedmatrix.com/trac/ticket/7274</a><br>
<div><br>I am interested in fixing this bug. What is the right way to get help from people who know the code? I have some simple questions I'd like to ask so that I go in the right direction while fixing this.<br><br>
-Daniel<br><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 30, 2014 at 8:09 PM, Daniel Sank <span dir="ltr"><<a href="mailto:sank.daniel@gmail.com" target="_blank">sank.daniel@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Dear Twisted users,<br><br></div>To my amazement I have reproduced this strange behaviour in an even simpler program. Attached are a pb client/server which illustrate unexpected behaviour of the id of a pb.RemoteCache. To run the example, run server.py and then client.py (with resources.py in the same working directory).<br>

<br></div>You will see output like this (line numbers added by me)<br><br>====<br>1. RemoteCache 29403544 initialized<br>2. Client received RemoteCache: id=29403544<br>3. RemoteCache: while responding to observe_add I think my id is 29403760<br>

4. Client: The RemoteCache's ide is 29403544<br>...<br>====<br><br></div>1. When the RemoteCache is initialized it thinks its id is 29403544.<br>2. The client agrees that it has received a RemoteCache with id 29403544.<br>

3. When the RemoteCache is inside observe_add it thinks its id is 29403760.<br>4. The client still thinks the RemoteCache's id is 29403544.<br><br>If you let the program run it will continue to loop between the RemoteCache reporting its id while in observe_add, and the client reporting the id of the RemoteCache. The two reported ids are always the same unequal numbers.<br>

<br></div>The question appears to be "Why does the id reported by a RemoteCache's while inside an observe_* method differ the id reported by objects owning references to that RemoteCache?"<br><br></div><div>

Thank you for your time,<br></div>Daniel<br><div><div><div><br><br></div></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 30, 2014 at 11:00 AM, Daniel Sank <span dir="ltr"><<a href="mailto:sank.daniel@gmail.com" target="_blank">sank.daniel@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Dear twisted users,<br><br></div>I think I have found some surprising behavior in perspective broker. I define a subclass of pb.RemoteCache which has a method managed by a descriptor. The descriptor keeps track of the instances it manages in a set.<br>


<br>When the RemoteCache is first received by the client, it accesses the descriptor-ified method inside setCopyableState. At that time the RemoteCache's id is a certain value X. Then later when the RemoteCache is notified of a change by the server side Cacheable, it again accesses the descriptor-ified method, but at this time it's id is Y, and Y!=X.<br>


<br></div>I attach to this post a simple working example which displays the behavior described above. To run, first run server.py and then run client.py. You will see a little bit of output, the most important part being<br>


<br>===<br>Client received RemoteCache: id=45952496<br></div><br></div><div>Asking server to update<br></div>TD 45921680 (test.RemoteCache.add) accessed by <test.RemoteCache instance at 2BD2DC8>: id=45952456<br></div>


RemoteCache id=45952496<div><div><div>===<br><br></div><div>To understand the details of the output please see descriptor.py. The id of the RemoteCache is first reported as 45952496 when the client receives it. Then, when the descriptor is accessed, the id of the accessing instance is reported as 45952456, which is different. Then, when in the last line we print out the id of the RemoteCache we're back to 45952496.<br>


<br></div><div>Is there some reason that a RemoteCache's id can change during its life time?<span><font color="#888888"><br clear="all"></font></span></div><span><font color="#888888"><div>
<div><div><div><div><br>-- <br>Daniel Sank<br>Department of Physics<br>Broida Hall<br>University of California<br>
Santa Barbara, CA 93117<br><a href="tel:%28805%29893-3899" value="+18058933899" target="_blank">(805)893-3899</a>
</div></div></div></div></div></font></span></div></div></div>
</blockquote></div><br><br clear="all"><br>-- <br>Daniel Sank<br>Department of Physics<br>Broida Hall<br>University of California<br>Santa Barbara, CA 93117<br><a href="tel:%28805%29893-3899" value="+18058933899" target="_blank">(805)893-3899</a>
</div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Daniel Sank<br>Department of Physics<br>Broida Hall<br>University of California<br>Santa Barbara, CA 93117<br>(805)893-3899
</div>