Thanks Murphy. I add a timer based call back mechanism, as you suggested, to
schedule sending data on socket.

Just wanted to confirm one more thing:

Is creating my own lock using thread.allocate_lock() allowed or not ? Since,
you mentioned thread is not allowed.

I have a data structure which is updated in different call backs like
openflow_datapath_join etc.. and this data structure needs to be sent to the
remote server when the timer gives the call back.

Regards,
Vishal

On Mon, Mar 28, 2011 at 10:32 AM, Murphy McCauley <jam...@nau.edu> wrote:

> Using threads from within Python in NOX is basically out.  You have a
> number of other options.
>
> If you just want to do something every second, maybe you can get away with
> using your socket code and just scheduling a timer callback (pyswitch does
> this to expire entries).  You will have to be somewhat careful to not block
> (for long), though.
>
> Two other possibilities are to use the messenger/jsonmessenger component
> (which is how the GUI communicates with the monitoring component), or making
> use of Twisted.  Kyriakos just mentioned these in a bit more detail on the
> mailing list the other day in the "Blocking Modules" thread.
>
> -- Murphy
>
> On Mar 28, 2011, at 7:10 AM, Vishal wrote:
>
> > Hi All,
> >
> > in the "install" function of pyswitch - I am starting a thread
> [thread.start_new_thread ()], which makes a socket connection to another
> server and sends some data every 1 second.
> >
> > I am observing that the thread is started but cannot send the data every
> 1 second... it is not scheduled for 5-10 seconds....and sends data randomly
> with lot of delay.
> >
> > Is there something wrong I am doing? or is there a scheduler where I need
> to register the thread ? (an app level thread scheduler) or twisted etc is
> interfering ?
> >
> > Any help is appreciated as I am new to python.
> >
> > Thanks a lot,
> > Vishal
> >
> > For running: I have modified pyswitch.py and restarted the nox_core with
> it..
> >
> > The function is below:
> > def serveclient(self):
> >     print 'serveclient'
> >     print self.host,self.port
> >     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> >     s.connect((self.add_host,self.add_port))
> >     print "connected"
> >     while 1:
> >         s.send('test data')
> >         time.sleep(1)
> >     s.close()
> >
> >
> >
> >
> > _______________________________________________
> > nox-dev mailing list
> > nox-dev@noxrepo.org
> > http://noxrepo.org/mailman/listinfo/nox-dev
>
>
_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev

Reply via email to