[nox-dev] TCP Server in NOX Component

2010-11-22 Thread Derek Cormier

Hello,

I am trying to run a thread inside of a python NOX component using 
twisted that listens for TCP connections. I added code to pyswitch.py to 
see if I could get it working. However, I am getting this seg fault from 
NOX. It seems to be failing at 'reactor.listenTCP(8007, factory)'. Any 
ideas on what the problem might be?


Added code:

class ServerThread(Thread):
def run(self):
print Thread started
factory = Factory()
factory.protocol = QOTD
reactor.listenTCP(8007, factory)
reactor.run()

class QOTD(LineReceiver):
def connectionMade(self):
self.transport.write(Vene, vidi, vici\n)
self.transport.loseConnection()

I added the following two lines at the end of pyswitch's install method:

self.serverThread = ServerThread()
self.serverThread.start()

NOX Output:

NOX 0.9.1~full~beta (nox_core), compiled Nov 11 2010 10:38:11
Compiled with OpenFlow 0x01
Thread started
Caught signal 11.
  0x7f47a8541262   64 (vigil::fault_handler(int)+0x42)
  0x7f47a79d5af0
  0x7f47a85a206b   64 (vigil::co_fsm_run(vigil::co_thread*)+0x4b)
  0x7f47a4cddc83
  0x7f47a4ce193c
  0x7f47a4ce1f1a
  0x7f47a6610313 18446604128078702928 (PyEval_EvalFrameEx+0x5483)
  0x7f47a6969440 18446744073666775329 (PyFrame_Type+0x0)
Segmentation fault


Thanks,
-Derek

___
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org


Re: [nox-dev] Importing Nox in Python Without Running Nox

2010-11-22 Thread Reid Price
Hi Alec,

Have you tried just adding the base directory to sys.path?  It would be the
level that matches the src/ directory structure, in the built/compiled
version.  I think you should then be able to do things like import
nox.netapps.discovery.discovery as discovery successfully.  Would this help
with what you're trying to do?  This worked for me at one point, but I
haven't tried it with recent versions of nox.

  -Reid

On Mon, Nov 22, 2010 at 9:07 PM, Alec Story av...@cornell.edu wrote:

 Hi,

 I'd like to be able to link against nox (for the purpose of running unit
 tests that depend on nox but don't actually need it to be running) without
 invoking the nox binary, in python.  If I try to do this naively by adding
 all of nox's subdirectories to sys.path, I get swig errors, so clearly
 that's not the right way to do it.

 Is there a way to get this linking to work?

 --
 Alec Story
 Cornell University
 Biological Sciences, Computer Science 2012

 ___
 nox-dev mailing list
 nox-dev@noxrepo.org
 http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org


___
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org


Re: [nox-dev] Importing Nox in Python Without Running Nox

2010-11-22 Thread Alec Story
I'm running a pretty old version of nox, but that change didn't help, I got
the same error:

  [...]
  File /home/openflow/pronto/src/frenetic_net.py, line 14, in module
-- file I'm trying to import without nox running
import nox.lib.core as nox_core
  File /home/openflow/noxcore/build/src/nox/lib/core.py, line 24, in
module
from nox.coreapps.pyrt.pycomponent import *
  File /home/openflow/noxcore/build/src/nox/coreapps/pyrt/pycomponent.py,
line 25, in module
_pycomponent = swig_import_helper()
  File /home/openflow/noxcore/build/src/nox/coreapps/pyrt/pycomponent.py,
line 21, in swig_import_helper
_mod = imp.load_module('_pycomponent', fp, pathname, description)
ImportError:
/home/openflow/noxcore/build/src/nox/coreapps/pyrt/_pycomponent.so:
undefined symbol: _ZTIN5vigil5EventE

My version information is:
NOX 0.8.0~core~beta (nox_core), compiled Aug 18 2010 14:32:14
Compiled with OpenFlow 0x01


On Tue, Nov 23, 2010 at 12:42 AM, Reid Price r...@nicira.com wrote:

 Hi Alec,

 Have you tried just adding the base directory to sys.path?  It would be the
 level that matches the src/ directory structure, in the built/compiled
 version.  I think you should then be able to do things like import
 nox.netapps.discovery.discovery as discovery successfully.  Would this help
 with what you're trying to do?  This worked for me at one point, but I
 haven't tried it with recent versions of nox.

   -Reid

 On Mon, Nov 22, 2010 at 9:07 PM, Alec Story av...@cornell.edu wrote:

 Hi,

 I'd like to be able to link against nox (for the purpose of running unit
 tests that depend on nox but don't actually need it to be running) without
 invoking the nox binary, in python.  If I try to do this naively by adding
 all of nox's subdirectories to sys.path, I get swig errors, so clearly
 that's not the right way to do it.

 Is there a way to get this linking to work?

 --
 Alec Story
 Cornell University
 Biological Sciences, Computer Science 2012

 ___
 nox-dev mailing list
 nox-dev@noxrepo.org
 http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org





-- 
Alec Story
Cornell University
Biological Sciences, Computer Science 2012
___
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org