<p>While everything the people above me have said is correct, I would suggest AMP as an alternative. It would allow you to send most basic Python data types in your messages.</p>
<div class="gmail_quote">On Mar 29, 2013 2:32 AM, &quot;<a href="mailto:succer110@tiscali.it">succer110@tiscali.it</a>&quot; &lt;<a href="mailto:succer110@tiscali.it">succer110@tiscali.it</a>&gt; wrote:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>I have made 2 application: </div><div>The client extract data from a sql server (10k lines), and send every line pickled to a &quot;collector&quot; server via socket.</div>
<div>The server uses twisted and receive every line, unpikle it and store the data in another sql server.</div><div><br></div><div>Everytime i start sending data from client to server, in the first 200 line (everytime a different line) **the server** throws an exception:</div>
<div>SOMETIMES it something like:</div><div><br></div><div>    Traceback (most recent call last):</div><div>      File &quot;collector2.py&quot;, line 81, in dataReceived</div><div>        self.count,account<span style="white-space:pre-wrap">        </span>= pickle.loads(data)</div>
<div>      File &quot;/usr/lib/python2.6/pickle.py&quot;, line 1374, in loads</div><div>        return Unpickler(file).load()</div><div>      File &quot;/usr/lib/python2.6/pickle.py&quot;, line 858, in load</div><div>        dispatch[key](self)</div>
<div>      File &quot;/usr/lib/python2.6/pickle.py&quot;, line 1138, in load_pop</div><div>        del self.stack[-1]</div><div>    IndexError: list assignment index out of range</div><div><br></div><div>But it&#39;s NOT every time the same. Printing my exception i red: </div>
<div>Exception: pop from empty list</div><div>Exception: list index out of range</div><div>Exception: &quot;&#39;&quot;</div><div>Exception: list assignment index out of range</div><div><br></div><div>Another strange errors is:</div>
<div>File &quot;/usr/lib/python2.6/pickle.py&quot;, line 1124, in find_class</div><div>    __import__(module)</div><div>exceptions.ImportError: No module named ond&#39;</div><div><br></div><div>    for i in listaSAI:</div>
<div>    <span style="white-space:pre-wrap">        </span>crm={}</div><div>        try:</div><div>    <span style="white-space:pre-wrap">                </span>crm[&#39;uid&#39;]=i[0]</div><div>    <span style="white-space:pre-wrap">        </span>except:</div>
<div>    <span style="white-space:pre-wrap">                </span>crm[&#39;uid&#39;]=None</div><div>    <span style="white-space:pre-wrap">        </span>try:</div><div>    <span style="white-space:pre-wrap">                </span>crm[&#39;type_cond&#39;]=i[01]</div>
<div>    <span style="white-space:pre-wrap">        </span>except:</div><div>    <span style="white-space:pre-wrap">                </span>crm[&#39;type_cond&#39;]=None</div><div>    <span style="white-space:pre-wrap">        </span>try:</div><div>    <span style="white-space:pre-wrap">                </span>crm[&#39;population_id&#39;]=i[2]</div>
<div>    <span style="white-space:pre-wrap">        </span>except:</div><div>    <span style="white-space:pre-wrap">                </span>crm[&#39;population_id&#39;]=None</div><div>    <span style="white-space:pre-wrap">        </span>try:</div><div>
    <span style="white-space:pre-wrap">                </span>crm[&#39;product_id&#39;]=i[3]</div><div>    <span style="white-space:pre-wrap">        </span>except:</div><div>    <span style="white-space:pre-wrap">                </span>crm[&#39;product_id&#39;]=None</div>
<div>    <span style="white-space:pre-wrap">        </span>try:</div><div>    <span style="white-space:pre-wrap">                </span>crm[&#39;a_id&#39;]=i[4]</div><div>    <span style="white-space:pre-wrap">        </span>except:</div><div>    <span style="white-space:pre-wrap">                </span>crm[&#39;a_id&#39;]=None</div>
<div>    <span style="white-space:pre-wrap">        </span>try:</div><div>    <span style="white-space:pre-wrap">                </span>crm[&#39;status&#39;]=i[5]</div><div>    <span style="white-space:pre-wrap">        </span>except:</div><div>    <span style="white-space:pre-wrap">                </span>crm[&#39;status&#39;]=None</div>
<div>    <span style="white-space:pre-wrap">        </span>#time.sleep(0.001)</div><div>    <span style="white-space:pre-wrap">        </span>serialized = pickle.dumps((count,crm))</div><div>    <span style="white-space:pre-wrap">        </span>#print &quot;sent num&quot;, count, crm</div>
<div>    <span style="white-space:pre-wrap">        </span>s.sendall(serialized)</div><div>    <span style="white-space:pre-wrap">        </span>count += 1</div><div><br></div><div><br></div><div>And my server:</div><div><br></div><div>
    def dataReceived(self, data):</div><div>    <span style="white-space:pre-wrap">        </span>try:</div><div>    <span style="white-space:pre-wrap">                </span>self.count,account<span style="white-space:pre-wrap">        </span>= pickle.loads(data)        </div>
<div>    <span style="white-space:pre-wrap">        </span>except Exception as e:</div><div>    <span style="white-space:pre-wrap">                </span>print &quot;Eccezione:&quot;, e</div><div>    <span style="white-space:pre-wrap">                </span>print self.count+1</div>
<div>    <span style="white-space:pre-wrap">                </span>print  data</div><div>    <span style="white-space:pre-wrap">                </span>print traceback.print_exc()</div><div><br></div><div><br></div><div><br></div><div>Printing the data in my client tells me that everything it&#39;s ok.</div>
<div>*If i try to slow down the process of sending using time.sleep(0.01) in my client, EVERYTHING IS FINE, and no exception are raised.*</div><div><br></div><div>What can i do to debug my code?</div><div><br></div><div>p.s. </div>
<div>I suspect that exceptions.ImportError: No module named ond&#39; refers to &quot;type_cond&quot; key in crm.</div><br><br>Invita i tuoi amici e Tiscali ti premia! Il consiglio di un amico vale più di uno spot in TV. Per ogni nuovo abbonato 30 € di premio per te e per lui! Un amico al mese e parli e navighi sempre gratis: <a href="http://freelosophy.tiscali.it/" target="_blank">http://freelosophy.tiscali.it/</a> <br>
<br><br>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
<br></blockquote></div>