Hi Martin,after playing around with twisted deferreds and callbacks/errbacks etc., I finally handled my blocking call - used for continuously reading kernel generated packets from a TAP device, and sending these through the OF controller - using twisted's reader functionality (as suggested by Kyle - thanks a lot!). In case someone else is interested in doing something similar, here is some code which got me started:
On 15.04.2010, at 17:58, Kyle Forster wrote: ...
class MyFileReader():
def __init__(self):
#open the file
def doRead(self):
#read from the file, sending an event back in to nox with
#inst.post(pyevent(MY_FILE_READER_EVENT, e))
...
#(dumb impementations of doWrite, fileno and connectionLost)
from twisted.internet import reactor
...
reactor.addReader(MyFileReader())
...
The file reader runs in the background and fires an event whenever new data is available on the file descriptor - very nice! I also came across this blog entry, which has some useful infos about using IReadDescriptor:
http://krondo.com/blog/?p=1445 Best regards, Zdravko On 15.04.2010, at 06:26, Martin Casado wrote:
I've not tried using Python threads within Nox. It very well could be broken. You can grep around src/nox/coreapps/pyrt/ to see the reactor implementation within Nox. I would suggest using Twisted event harness and deferred's rather than Python threads..martinHello *,I recently started working on a project using NOX. I'm wondering how (if at all) I can use python threads in my controller (I want to use theseto handle a blocking function call). I came across this post, dealing with a similar problem: http://www.mail-archive.com/[email protected]/msg00430.htmlwhere it is hinted, that using the twisted framework would be the right approach. So far I've tried (unsuccessfully) using the callInThread and deferToThread functions from twisted. Are these functions implemented in the NOX reactor? Also, is my assumption that reactor.run() is executedautomatically by NOX correct? I would be very thankful for any pointers! Best regards, Zdravko _______________________________________________ nox-dev mailing list [email protected] http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org
PGP.sig
Description: This is a digitally signed message part
_______________________________________________ nox-dev mailing list [email protected] http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org
