Ye Olde Clue

Random musings on random stuff.

Multiple Windows in Pygame, using true concurrency in python via Kamaelia

First of all, the proof that this works in Kamaelia, right now:


OK, this is using the new code for running multiple Kamaelia type systems in multiple processes relatively simply. Specifically, the "interesting" code looks like this:

class SecondProcessBasedComponent(SimplestProcessComponent):
    def main(self):
        from Kamaelia.UI.Pygame.Display import PygameDisplay
        from Kamaelia.UI.Pygame.MagnaDoodle import MagnaDoodle

        X=PygameDisplay(width=200,height=200).activate()
        PygameDisplay.setDisplayService(X)
        MagnaDoodle().run()
        yield 1

exchange = SecondProcessBasedComponent().activate()
R = []
for _ in xrange(7):
     R.append(SecondProcessBasedComponent().activate())

The upshot? If the above code ran on a machine with 8 CPUs, it would use all 8 CPUs. With NO change to the pre-existing Kamaelia components. I find that pretty neat :-D

Reply to this post

Comments

Perhaps worth noting... #

... that the program wouldn't be able to open 8 windows if they weren't process level things.

-- Michael, 5 Dec 2007 at 03:10, Rating: 0 (Reply) (Moderated by: anon)

Back to front page