<div dir="ltr">Už to asi vidím, každý klient má své vlákno (leda že by se samotný klient používal vícevláknově). Příště si dám větší pauzu před odesláním :)<div><br></div><div><div><br></div><div>PM</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">Dne 10. února 2015 14:39 Petr Messner <span dir="ltr"><<a href="mailto:petr.messner@gmail.com" target="_blank">petr.messner@gmail.com</a>></span> napsal(a):<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Jak jsou jednotlivé zprávy od sebe odděleny? Vidím tam v klientovi<div><br></div><div><pre style="margin-top:0px;margin-bottom:0px;padding:0px;border:none;outline:0px;font-size:12px;vertical-align:baseline;font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;color:rgb(68,68,68);overflow:inherit;font-stretch:normal;background:rgb(241,241,241)"><br>    <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(32,74,135);font-weight:bold;background:transparent">def</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background:transparent">communicate</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">(</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(52,101,164);background:transparent">self</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">,</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">data</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">):</span>
        <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(52,101,164);background:transparent">self</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">.</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">_socket</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">.</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">send</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">(</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(78,154,6);background:transparent">'</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(78,154,6);background:transparent">%s</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(78,154,6);background:transparent"> </span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(78,154,6);background:transparent">%s</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(78,154,6);background:transparent">'</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">%</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">(</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(52,101,164);background:transparent">self</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">.</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">name</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">,</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">data</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">))</span>
        <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(52,101,164);background:transparent">self</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">.</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">_socket</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">.</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">recv</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">(</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(52,101,164);background:transparent">self</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">.</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">buffer_size</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">)</span>
      </pre></div><div class="gmail_extra"><br><div class="gmail_quote">A server to čte takto:</div><div class="gmail_quote"><pre style="margin-top:0px;margin-bottom:0px;padding:0px;border:none;outline:0px;font-size:12px;vertical-align:baseline;font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;color:rgb(68,68,68);overflow:inherit;font-stretch:normal;background:rgb(241,241,241)">        <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(32,74,135);font-weight:bold;background:transparent">while</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(52,101,164);background:transparent">True</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">:</span>
            <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">data</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">=</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(52,101,164);background:transparent">self</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">.</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">_socket</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">.</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">recv</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">(</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(52,101,164);background:transparent">self</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">.</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">buffer_size</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">)</span>
            
            <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(32,74,135);font-weight:bold;background:transparent">if</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">data</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(32,74,135);font-weight:bold;background:transparent">in</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">(</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(78,154,6);background:transparent">''</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">,</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(78,154,6);background:transparent">'</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(78,154,6);background:transparent">\n</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(78,154,6);background:transparent">'</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">,</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(78,154,6);background:transparent">'</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(78,154,6);background:transparent">\r\n</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(78,154,6);background:transparent">'</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">):</span>
                <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(32,74,135);font-weight:bold;background:transparent">return</span>
            
            <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(32,74,135);font-weight:bold;background:transparent">try</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">:</span>
                <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">who</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">,</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">op</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">,</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">name</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">=</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">data</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">.</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">split</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">()</span>
            <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(32,74,135);font-weight:bold;background:transparent">except</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(204,0,0);font-weight:bold;background:transparent">ValueError</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">:</span>
                <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(32,74,135);font-weight:bold;background:transparent">raise</span> <span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(204,0,0);font-weight:bold;background:transparent">ValueError</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">(</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(78,154,6);background:transparent">'Invalid data'</span><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">)</span>
            </pre></div><div class="gmail_quote"><br></div><div class="gmail_quote">Co když se zprávy pošlou náhodou tak, že <span style="font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:12px;margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(52,101,164);background:transparent">self</span><span style="font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:12px;margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">.</span><span style="font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:12px;margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">_socket</span><span style="font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:12px;margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">.</span><span style="font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:12px;margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">recv</span><span style="font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:12px;margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">(</span><span style="font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:12px;margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(52,101,164);background:transparent">self</span><span style="font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:12px;margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(206,92,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">.</span><span style="font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:12px;margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);background-image:initial;background-repeat:initial">buffer_size</span><span style="font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:12px;margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;color:rgb(0,0,0);font-weight:bold;background-image:initial;background-color:transparent;background-repeat:initial">)</span> přijme dvě zprávy najednou? To mu pak přijde něco jako <font face="monospace, monospace">"client1 mklock lock1client2 mklock lock2" </font>a nebude to fungovat - server spadne.</div><div class="gmail_quote"><br></div><div class="gmail_quote">PM</div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote">Dne 10. února 2015 14:15 Pavel S <span dir="ltr"><<a href="mailto:pavel@schon.cz" target="_blank">pavel@schon.cz</a>></span> napsal(a):<div><div class="h5"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Jeste existuje tzv. DLM (Distributed Lock Manager). Zjednodusene receno, je to mutex, ktery je pristupny po siti.<br>
<br>
Jeden takovy jednoduchy distributed lock manager jsem napsal v pythonu a umistil na activestate zde: <a href="http://code.activestate.com/recipes/578194-distributed-lock-manager-for-python/" target="_blank">http://code.activestate.com/recipes/578194-distributed-lock-manager-for-python/</a><br>
<div><div>_______________________________________________<br>
Python mailing list<br>
<a href="mailto:python@py.cz" target="_blank">python@py.cz</a><br>
<a href="http://www.py.cz/mailman/listinfo/python" target="_blank">http://www.py.cz/mailman/listinfo/python</a><br>
<br>
Visit: <a href="http://www.py.cz" target="_blank">http://www.py.cz</a><br>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div>