Hi Murphy, Thanks alot for the immediate response!
This certainly helped me but I am hitting another snag when using Task and unfortunately theres not alot of documentation so I would be grateful if you could help me out on this. Please see attachment for code. What I am trying to achieve is automate for all possible combination of matches using bit manipulation and then in turn use all actions for L2 headers. But the problems I am facing are: >>The Task is getting executed twice. I really dont understand why >>When Connection is being called, an error is thrown suggesting its NoneType and has no attribute "send". Thanks alot for your response again and please let me know if I am missing something painfully obvious because i have tried every permutation and combination but am not able to understand why it is being called twice or how to bypass the connection object error. Regards, Vinay Pai B.H. On Tue, Oct 29, 2013 at 12:23 AM, Murphy McCauley <[email protected] > wrote: > Timers are independent, so what you are seeing is the expected behavior. > > How is your "X" factoring into the example? It appears they should > continue forever... unless you have something (not shown) which cancels > them. If so, that's pretty much the answer to your question: to get them > to be sequential, when you cancel the first one, start the second one one. > You could have a "to do" list to give it a bit more structure (where each > time the Timer executes, you check the to do list). > > But I think using a Timer may just not be the easiest way to go about > doing what you want. You may be better off just writing a Task to do it. > Here's an example which does one thing seven times, does another three > times, and waits for two seconds between each. > > from pox.lib.recoco import Task, Sleep > > class MyTask (Task): > def run (self): > for _ in range(7): > print "Thing 1" > yield Sleep(2) > > for _ in range(3): > print "Thing 2" > yield Sleep(2) > > > def launch (): > t = MyTask() > t.start() > > Hope that helps. > > -- Murphy > > On Oct 28, 2013, at 11:14 PM, vinay pai <[email protected]> wrote: > > Hi All, > > I am trying to write an application which automates and pushes flows so > that I can test the functionality of my switch. However I am encountering a > small problem. > > What I am trying to achieve is as follows: > > <call *function_1()* 'X' times with a timeout of 'Y' seconds with *arguments > 'J' and 'K'*> > <call *function_1()* 'X' times with a timeout of 'Y' seconds with *arguments > 'L' and 'M'*> > ...and so on > > Python code wise: > > Timer(10,app,recurring = True, args=["port",0]) > Timer(10,app,recurring = True, args=["controller",1]) > ...and so on > > (Here Y = 10 seconds) > > What I was expecting to see was app() function gets called X times with a > timeout of 10 seconds and the arguments as "port" and 0. Next app() > function with arguments "controller" and 1 gets called and so on. > > What I am seeing is both versions of app() function (with different > arguments) get called at the same time and wait for 10 seconds and get > called again at the same time, for X number of times. > > Is this the expected behavior for Timer? Is there an alternative where in > I can go sequentially? even if I embed the second Timer call in a function > and call that function after the first Timer function, both get called at > the same time. > > I have done git clone yesterday so I think its safe to say I am using the > latest version. > Currently I am running this program against Mininet Version 2.0.0 > > There's less documentation with respect to Timer because of which I am not > sure if I am missing something very obvious. Any help will be greatly > appreciated. > > Regards, > > Vinay Pai B.H. > > -- > Vinay Pai B.H. > Grad Student - Computer Science > Viterbi School of Engineering > University of Southern California > Los Angeles, CA, USA > > > -- Vinay Pai B.H. Grad Student - Computer Science Viterbi School of Engineering University of Southern California Los Angeles, CA, USA
automate.py
Description: Binary data
