nuXleus Preview Release 1 + Question re: Axon/Kamaelia integration

1 view
Skip to first unread message

M. David Peterson

unread,
Jan 2, 2007, 8:10:21 PM1/2/07
to llup
Hey All,

Completely spaced updating the list with the announcement I made earlier today  > http://www.oreillynet.com/xml/blog/2007/01/annnuxleus_the_nuxleus_project.html

Still quite a bit more work to do, but its FINALLY getting into a state of being useful for most of the tasks that have been dog eared to be a part of the final release.

NOTE: I've integrated both Axon and Kamaelia, though haven't done any testing as of yet. 

Michael: Are there any known issues with running either Axon or Kamaelia under Python 2.5?

Thanks in advance!

--
/M:D

M. David Peterson
http://mdavid.name | http://www.oreillynet.com/pub/au/2354

Michael Sparks

unread,
Jan 3, 2007, 6:44:31 AM1/3/07
to ll...@googlegroups.com
On 1/3/07, M. David Peterson <xmlh...@gmail.com> wrote:
> Michael: Are there any known issues with running either Axon or Kamaelia
> under Python 2.5?

There aren't any known issues. In fact, it's likely to make people's
lives easier.
The reason for this is because python 2.5 allows the following construct:

try:
DoSomethingThatMightBreak()
finally:
exitLoop = True

inside a generator, allowing things like:

def main(self):
exitLoop = False
while not exitLoop:
try:
DoSomethingThatMightBreak()
finally:
exitLoop = True
yield 1

It used to be the case you couldn't do that (put a finally clause in a
generator) - you had to do something like this:

from lines 217 onwards of :

http://svn.sourceforge.net/viewvc/kamaelia/trunk/Code/Python/Kamaelia/Kamaelia/Internet/TCPClient.py?revision=2515&view=markup

try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM); yield 0.3
self.sock = sock
try:
sock.setblocking(0); yield 0.6
try:
while not self.safeConnect(sock,(self.host, self.port)):
if self.shutdown(): return
yield 1
yield newComponent(*self.setupCSA(sock))
while self.waitCSAClose():
self.pause()
yield 2
raise Finality
except Exception, x:
result = sock.shutdown(2) ; yield 3
raise x
except Exception, x:
sock.close() ; yield 4,x
raise x
except Finality:
yield 5
except socket.error, e:
self.send(shutdownMicroprocess(self), "signal")

That can now be simplified to:
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM); yield 0.3
self.sock = sock
try:
sock.setblocking(0); yield 0.6
try:
while not self.safeConnect(sock,(self.host, self.port)):
if self.shutdown(): return
yield 1
yield newComponent(*self.setupCSA(sock))
while self.waitCSAClose():
self.pause(); yield 2
finally:
result = sock.shutdown(2) ; yield 3
finally:
sock.close() ; yield 4,x
finally:
yield 5
except socket.error, e:
self.send(shutdownMicroprocess(self), "signal")

(the numbered yields are just useful for debugging/testing, and only
have significance for that purpose, nothing else)

That said, we don't currently take advantage of any 2.5 features,
largely because our code is still python 2.2 compatible. (Which
means there's no reason it won't run on Series 60 mobiles for
example, though in practice, it's been significant time since we
tested that).

At some point we probably will add in python 2.5 features, probably
something like have a threaded generator component. The advantage
of putting a generator into a thread is non-obvious - if you do, you gain
the ability to kill the thread by killing the generator - since you can now
send exceptions into generators.

That said, I personally haven't had a chance to test with python 2.5,
since I prefer to use a prebuilt distribution rather than build my own
binaries. (I can do that, but got bored of the admin overhead sometime
ago! :-)

I suppose it's time to upgrade my distro...

Happy New Year all,

Regards,


Michael

M. David Peterson

unread,
Jan 3, 2007, 10:57:08 AM1/3/07
to ll...@googlegroups.com
Thanks for this, Michael!  Happy New Year to you as well!

                  if self.shutdown (): return

                  yield 1
               yield newComponent(*self.setupCSA(sock))
               while self.waitCSAClose():
                  self.pause()
                  yield 2
               raise Finality
            except Exception, x:
               result = sock.shutdown(2) ; yield 3
               raise x
         except Exception, x:
            sock.close() ;  yield 4,x
            raise x
      except Finality:
         yield 5
      except socket.error, e:
         self.send(shutdownMicroprocess(self), "signal")

That can now be simplified to:
      try:
         sock = socket.socket(socket.AF_INET , socket.SOCK_STREAM); yield 0.3

         self.sock = sock
         try:
            sock.setblocking(0); yield 0.6
            try:
               while not self.safeConnect(sock,(self.host, self.port)):
                  if self.shutdown(): return
                  yield 1
               yield newComponent(*self.setupCSA(sock))
               while self.waitCSAClose():
                  self.pause(); yield 2
            finally:
               result = sock.shutdown(2) ; yield 3
         finally:
            sock.close() ;  yield 4,x
      finally:
         yield 5
      except socket.error, e:
         self.send (shutdownMicroprocess(self), "signal")


(the numbered yields are just useful for debugging/testing, and only
have significance for that purpose, nothing else)

That said, we don't currently take advantage of any 2.5 features,
largely because our code is still python 2.2 compatible. (Which
means there's no reason it won't run on Series 60 mobiles for
example, though in practice, it's been significant time since we
tested that).

At some point we probably will add in python 2.5 features, probably
something like have a threaded generator component. The advantage
of putting a generator into a thread is non-obvious - if you do, you gain
the ability to kill the thread by killing the generator - since you can now
send exceptions into generators.

That said, I personally haven't had a chance to test with python 2.5,
since I prefer to use a prebuilt distribution rather than build my own
binaries. (I can do that, but got bored of the admin overhead sometime
ago! :-)

I suppose it's time to upgrade my distro...

Happy New Year all,

Regards,


Michael

Reply all
Reply to author
Forward
0 new messages