[IPython-user] Parallel OO programming in Python

Brian Granger ellisonbg.net at gmail.com
Mon Nov 6 20:56:49 CST 2006


The IPython controller listens on two ports:

1.  For engines on port 10201
2.  For "vanilla" clients on 10105

You are a client, but you connected on the engine port.  If you do:

rc = kernel.RemoteController(('localhost', 10105))

it should work fine.

the kernel module also as a defaultController attribute that is:

kernel.defaultController = ('127.0.0.1', 10105)

So as long as the controller is (i) on the same machine as the client
and (ii) is using the default ports, you should be able to do:

rc = kernel.RemoteController(kernel.defaultController)

See if that works.

Brian

On 11/6/06, Flavio Coelho <fccoelho at gmail.com> wrote:
> Allright! thanks!
>
> Now it passes all the tests! So far so good!
>
> Now the problem is in getting the engine and the controller to connect:
>
> flavio at localhost ~ $ 2006/11/06 22:26 -0200 [-] Log opened.
> 2006/11/06 22:26 -0200 [-] <class '
> ipython1.kernel.enginevanilla.VanillaEngineServerFactoryFromControllerService'>
> starting on 10201
> 2006/11/06 22:26 -0200 [-] Starting factory
> <ipython1.kernel.enginevanilla.VanillaEngineServerFactoryFromControllerService
> object at 0xb693a52c>
> 2006/11/06 22:26 -0200 [-] <class
> 'ipython1.kernel.controllervanilla.VanillaControllerFactoryFromService'>
> starting on 10105
> 2006/11/06 22:26 -0200 [-] Starting factory
> <ipython1.kernel.controllervanilla.VanillaControllerFactoryFromService
> object at 0xb694910c>
> 2006/11/06 22:26 -0200 [-]
> twisted.spread.pb.PBServerFactory starting on 10111
> 2006/11/06 22:26 -0200 [-] Starting factory
> <twisted.spread.pb.PBServerFactory instance at 0xb694920c>
>
> flavio at localhost ~ $ ipengine &
> [2] 26607
> flavio at localhost ~ $ 2006/11/06 22:26 -0200 [-] Log opened.
> 2006/11/06 22:26 -0200 [-] Starting factory
> <ipython1.kernel.enginevanilla.VanillaEngineClientFactoryFromEngineService
> object at 0xb69a7dcc>
> 2006/11/06 22:26 -0200 [VanillaEngineServerProtocol,0,127.0.0.1] registered
> engine: 0
>
> flavio at localhost ~ $ ipython
> WARNING: Could not import user config!
>  ('/home/flavio/.ipython/ipy_user_conf.py' does not exist?
> Please run '%upgrade')
>
> Total number of aliases: 15
> Python 2.4.4 (#1, Nov  5 2006, 15:46:15)
> Type "copyright", "credits" or "license" for more information.
>
> IPython 0.7.2 -- An enhanced Interactive Python.
> ?       -> Introduction to IPython's features.
> %magic  -> Information about IPython's 'magic' % functions.
> help    -> Python's own help system.
>  object? -> Details about 'object'. ?object also works, ?? prints more.
>
> In [1]:import ipython1.kernel.api as kernel
>
> In [2]:rc = kernel.RemoteController?
> Object `rc = kernel.RemoteController` not found.
>
> In [3]:kernel.RemoteController?
> Type:           type
> Base Class:     <type 'type'>
> String Form:    <class
> 'ipython1.kernel.controllervanilla.RemoteController'>
> Namespace:      Interactive
> File:
> /usr/lib/python2.4/site-packages/ipython1/kernel/controllervanilla.py
> Docstring:
>     A high level interface to a remotely running IPython controller.
>
>
> In [4]:rc = kernel.RemoteController(('192.168.1.101',10201))
>
> In [5]:rc.getIDs()
>  2006/11/06 22:27 -0200 [VanillaEngineServerProtocol,1,192.168.1.101]
> Unhandled Error
>         Traceback (most recent call last):
>           File
> "/usr/lib/python2.4/site-packages/twisted/python/log.py",
> line 48, in callWithLogger
>             return callWithContext({"system": lp}, func, *args, **kw)
>           File
> "/usr/lib/python2.4/site-packages/twisted/python/log.py",
> line 33, in callWithContext
>             return context.call ({ILogContext: newCtx}, func, *args, **kw)
>           File
> "/usr/lib/python2.4/site-packages/twisted/python/context.py",
> line 59, in callWithContext
>             return self.currentContext().callWithContext(ctx, func, *args,
> **kw)
>           File
> "/usr/lib/python2.4/site-packages/twisted/python/context.py",
> line 37, in callWithContext
>             return func(*args,**kw)
>         --- <exception caught here> ---
>           File
> "/usr/lib/python2.4/site-packages/twisted/internet/selectreactor.py",
> line 139, in _doReadOrWrite
>             why = getattr(selectable, method)()
>           File
> "/usr/lib/python2.4/site-packages/twisted/internet/tcp.py",
> line 362, in doRead
>             return self.protocol.dataReceived(data)
>           File
> "/usr/lib/python2.4/site-packages/twisted/protocols/basic.py",
> line 99, in dataReceived
>             self.doData()
>           File
> "/usr/lib/python2.4/site-packages/twisted/protocols/basic.py",
> line 62, in doData
>             self.stringReceived(self.__buffer)
>           File
> "/usr/lib/python2.4/site-packages/ipython1/kernel/enginevanilla.py",
> line 557, in stringReceived
>             self.nextHandler(msg)
>           File
> "/usr/lib/python2.4/site-packages/ipython1/kernel/enginevanilla.py",
> line 575, in dispatch
>             self.dieLoudly('Command could not be dispatched: ' + msg)
>           File
> "/usr/lib/python2.4/site-packages/ipython1/kernel/enginevanilla.py",
> line 585, in dieLoudly
>             log.msg('Protocol Error [%i]: ' % id + repr(a))
>         exceptions.TypeError: int argument required
>
> 2006/11/06 22:27 -0200 [VanillaEngineServerProtocol,1,192.168.1.101]
> unregistered engine None
> 2006/11/06 22:27 -0200 [VanillaEngineServerProtocol,1, 192.168.1.101]
> Unhandled Error
>         Traceback (most recent call last):
>           File "/usr/bin/ipcontroller", line 51, in main
>             reactor.run()
>           File
> "/usr/lib/python2.4/site-packages/twisted/internet/posixbase.py",
> line 218, in run
>             self.mainLoop()
>           File
> "/usr/lib/python2.4/site-packages/twisted/internet/posixbase.py",
> line 229, in mainLoop
>             self.doIteration(t)
>           File
> "/usr/lib/python2.4/site-packages/twisted/internet/selectreactor.py",
> line 133, in doSelect
>             _logrun(selectable, _drdw, selectable, method, dict)
>         --- <exception caught here> ---
>           File
> "/usr/lib/python2.4/site-packages/twisted/python/log.py",
> line 48, in callWithLogger
>             return callWithContext({"system": lp}, func, *args, **kw)
>           File
> "/usr/lib/python2.4/site-packages/twisted/python/log.py",
> line 33, in callWithContext
>             return context.call ({ILogContext: newCtx}, func, *args, **kw)
>           File
> "/usr/lib/python2.4/site-packages/twisted/python/context.py",
> line 59, in callWithContext
>             return self.currentContext().callWithContext(ctx, func, *args,
> **kw)
>           File
> "/usr/lib/python2.4/site-packages/twisted/python/context.py",
> line 37, in callWithContext
>             return func(*args,**kw)
>           File
> "/usr/lib/python2.4/site-packages/twisted/internet/selectreactor.py",
> line 149, in _doReadOrWrite
>             self._disconnectSelectable(selectable, why,
> method=="doRead")
>           File
> "/usr/lib/python2.4/site-packages/twisted/internet/posixbase.py",
> line 256, in _disconnectSelectable
>             selectable.connectionLost(failure.Failure(why))
>           File
> "/usr/lib/python2.4/site-packages/twisted/internet/tcp.py",
> line 416, in connectionLost
>             protocol.connectionLost(reason)
>           File
> "/usr/lib/python2.4/site-packages/ipython1/kernel/enginevanilla.py",
> line 538, in connectionLost
>             self.factory.unregisterEngine(self.id)
>           File
> "/usr/lib/python2.4/site-packages/ipython1/kernel/enginevanilla.py",
> line 1023, in unregisterEngine
>             return self.service.unregisterEngine(id)
>           File
> "/usr/lib/python2.4/site-packages/ipython1/kernel/controllerservice.py",
> line 300, in unregisterEngine
>             del self.engines[id]
>         exceptions.KeyError :
>
>
>
> On 11/6/06, Brian Granger <ellisonbg.net at gmail.com> wrote:
> > I would first delete the old version of the zope directory that is in
> > your site-packages directory.
> > You can find this directory using:
> >
> > import distutils.sysconfig as sc
> > sc.get_python_lib()
> >
> > Brian
> >
> > On 11/6/06, Flavio Coelho <fccoelho at gmail.com> wrote:
> > >
> > >
> > > Brian,
> > >
> > >  I dowloaded ZopeInterface 3.1c1 and installed it with 'python setup.py
> > > install' Is there anything else to it?
> > >
> > >
> > > Flavio
> > >
> > > On 11/6/06, Brian Granger <ellisonbg.net at gmail.com> wrote:I have
> reponded on
> > > the ipython-users list.  But just for the record,
> > > this still looks like you don't have a new enough version of
> > > ZopeInterface.
> > >
> > > Brian
> > >
> > > --
> > > Flávio Codeço Coelho
> > > registered Linux user # 386432
> > > ---------------------------
> > > "Laws are like sausages. It's better not to see them being made."
> > > Otto von Bismark
> > >
> > > --
> > > Flávio Codeço Coelho
> > > registered Linux user # 386432
> > > ---------------------------
> > > "Laws are like sausages. It's better not to see them being made."
> > > Otto von Bismark
> > > _______________________________________________
> > > IPython-user mailing list
> > > IPython-user at scipy.org
> > > http://projects.scipy.org/mailman/listinfo/ipython-user
> > >
> > >
> > >
> >
>
>
>
> --
>
> Flávio Codeço Coelho
> registered Linux user # 386432
> ---------------------------
> "Laws are like sausages. It's better not to see them being made."
> Otto von Bismark


More information about the IPython-user mailing list