<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">You misunderstood. I said you should use a thread. If your thread needs to communicate information back to the main thread, it can use core.callLater() to do that.<div><br></div><div>-- Murphy</div><div><br><div><div>On Jul 24, 2013, at 12:57 AM, Hong Wayne wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Hong Wayne</b> <span dir="ltr"><<a href="mailto:wayne21205@gmail.com">wayne21205@gmail.com</a>></span><br>
Date: 2013/7/24<br>Subject: Re: [pox-dev] POX disconnected to OpenFlow switch<br>To: Murphy McCauley <<a href="mailto:murphy.mccauley@gmail.com">murphy.mccauley@gmail.com</a>><br><br><br><div dir="ltr">Hello Murphy:<div>
<br></div><div><br></div><div>Thank you for replying.</div><div><br></div><div><span style="font-family:arial,sans-serif;font-size:18px">In your suggestion, I can use </span><span style="font-family:arial,sans-serif;font-size:18px">core.callLater()</span><span style="font-family:arial,sans-serif;font-size:18px"> to execute </span><font face="arial, sans-serif">time consuming program,</font><span style="font-family:arial,sans-serif;font-size:18px"> </span></div>
<div><span style="font-family:arial,sans-serif;font-size:18px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:18px">But in POX Wiki, The u</span><font face="arial, sans-serif">tility for</font><span style="font-size:18px;font-family:arial,sans-serif"> </span><span style="font-size:18px;font-family:arial,sans-serif">Timer is almost same like callLater.</span></div>
<div><span style="font-family:arial,sans-serif;font-size:18px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:18px">So I use Timer to trigger time </span><span style="font-family:arial,sans-serif">consuming program(</span><span style="font-family:arial,sans-serif;font-size:18px">_handle_timer_temp</span><span style="font-family:arial,sans-serif">) like below:</span></div>
<div><span style="font-family:arial,sans-serif;font-size:18px">Timer( float(self.interval), _handle_timer_temp, recurring=False, args=(core.openflow, self.return_nu_rows, self.return_switch_info))</span></div><div><br></div>
<div>But still get disconnect form OF switch, did I have any wrong about this opinion?</div><div><br></div><div>Can you give me more information or examples? Thanks for helping again.</div><div><br></div></div><div class="HOEnZb">
<div class="h5"><div class="gmail_extra">
<br><br><div class="gmail_quote">2013/7/24 Murphy McCauley <span dir="ltr"><<a href="mailto:murphy.mccauley@gmail.com" target="_blank">murphy.mccauley@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Ten seconds is much longer than you want to stall the main thread. You should do time consuming computations in another thread. If they need to communicate back to the main thread, there are a number of ways to do it... usually, it's sufficient to just call core.callLater() and pass the data as arguments when your time consuming computation finishes.<span><font color="#888888"><div>
<br></div></font></span><div><span><font color="#888888">-- Murphy</font></span><div><div><br><div><div><br><div><div>On Jul 24, 2013, at 12:13 AM, Hong Wayne wrote:</div><br><blockquote type="cite">
<div dir="ltr">Sorry about that.<br><br>POX command line:<br>./pox.py forwarding.l2_learning openflow.of_01 --address=ip_address --port=6633 samples.pretty_log log.level --packet=WARN myself_module --interval=2<br><br>POX version: betta<div>
<br></div><div>OF switch: Open vSwitch 1.9</div><div><br></div><div>And the code in myself_module is done the things that execute algorithm and update database(Written in _handle_timer_temp callback function) which cost about ten seconds and myself_module will be triggered by _handle_ConnectionUp like below:</div>
<div><br></div><div><div>class temp_class (object):</div><div><br></div><div> def __init__ (self, interval):</div><div><br></div><div> core.openflow.addListeners(self)</div><div> self.interval = interval</div><div>
db = MySQLdb.connect(host="", user="", passwd="", db="")</div><div> cursor = db.cursor()#Create instance to access DB</div><div> cursor.execute("SELECT dpid, Dead, Maskbit, c_subnet_start, c_subnet_end, Load_balancing_algorithm FROM Pica8_Switch_Info ")</div>
<div> self.return_nu_rows = cursor.rowcount </div><div> self.return_switch_info = cursor.fetchall()</div><div> db.close()</div><div><br></div><div> def _handle_ConnectionUp (self, event):</div><div><br></div><div>
log.debug("Default Connection %s" % (event.connection,))</div><div><br></div><div> Timer(float(self.interval), _handle_timer_temp, recurring=False, args=(core.openflow, self.return_nu_rows, self.return_switch_info))</div>
<div><br></div><div><br></div><div>def launch (interval): #User parameters</div><div> """</div><div> Starts modules</div><div> """</div><div> core.registerNew( Wayne_class, interval)</div>
</div><div><br></div><div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/7/24 Murphy McCauley <span dir="ltr"><<a href="mailto:murphy.mccauley@gmail.com" target="_blank">murphy.mccauley@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don't think you've provided enough information for an explanation to be offered.<br>
<br>
Please see the final question on the POX wiki's FAQ for guidance to help us help you.<br>
<span><font color="#888888"><br>
-- Murphy<br>
</font></span><div><div><br>
On Jul 23, 2013, at 9:23 PM, Hong Wayne wrote:<br>
<br>
> Dear all:<br>
><br>
><br>
> I faced a problem when OpenFlow switch connect to POX and some module I modified triggered at this time(ConnectionUp event) and cost some times.<br>
><br>
> When this module was executed completely, the POX command line appear the messages like below:<br>
><br>
> [openflow.of_01] already disconnected!<br>
> [openflow.of_01] closed connection<br>
> [openflow.of_01] disconnected<br>
><br>
> So I want to ask why these error message happened? Whether POX run some module I didn't notice?<br>
><br>
> Thanks for helping.<br>
</div></div></blockquote></div><br></div>
</blockquote></div><br></div></div></div></div></div></div></blockquote></div><br></div>
</div></div></div><br></div>
</blockquote></div><br></div></body></html>