[Sidefx-houdini-list] Python in Houdini 9

Lutz Paelike lutz_p at gmx.net
Thu Nov 2 08:21:04 EST 2006


Dante Allegria schrieb:
> On Tue, October 31, 2006 13:31, Lutz Paelike said:
>> A saner and more stable approach (for the host environment, houdini
> in
>> this case)
>> would be to run your custom simulation in a separate process
>> on a another processor (core or computer) and bridge it with a
> network
>> connection.
> 
> Can't you do that already now in Houdini 8.1?
> 
> http://odforce.net/wiki/index.php/PythonToHoudini
> 
> 
> 
> dante
> 

That's true, but you have to transfer all your data as text data which is annoying and also a performance killer.

If python is integrated you could do something like the example below (little pseudo code)
The network handling code is omitted here.
You could use a simple socket connection, some ORB library like pyro (http://pyro.sourceforge.net/)
or the really cool twisted python library (http://www.twistedmatrix.com).
it's up to you.

Twisted Python is really fast and powerful but has it's own event loop which makes it a little difficult
to integrate if houdini doesn't call the event processing on a regular basis (see my last post).

if the simulation is running on the same computer you might even consider using shared memory via posh
http://poshmodule.sourceforge.net instead of a network connection and avoid a lot of speed penalty caused
by data transfer.

Cheers,

Lutz

------------------------------------

class MySimulation:
   """
   your class definition here
   """


# on the houdini side
if simulator_connection.result_ready():
    result = simulator_connection.get_result()
    # got the MySimulation instance here
    import pickle
    mysimulation = pickle.loads(result)
    # do something with the result ...
    # you got a MySimulation instance here !

# on the simulator side

class SimulationServer:
   """
   your network handling boilerplate
   code here ...
   """
   def __init__(self):
	self.networkconnection = MyNetworkConnection()
	self.simulation = MySimulation()

   def result_ready(self):
	"""
	calulation finished
	"""
	self.networkconnection.send(self.simulation.is_finished)

   def get_result(self):
	"""
	send result
	"""
	import pickle
	result = pickle.dumps(self.simulation)
	self.networkconnection.send(result)
------------------------------------



More information about the Sidefx-houdini-list mailing list