Python opening multiple thread of matlab

2006-11-11 Thread tsjuan
Hello Python Users,

I've been trying to run multiple thread of Matlab by calling its com
object
via python. However, I keep getting error message that says Python
can't
find the attribute of certain function that I want to execute in
Matlab.

I know the com function is exist, it works just fine if I don't run
within thread.
Below is my sample code, any helps or comments are appreciated.

Thanks,
Tanto

import threading
from win32com.client import Dispatch


class MyThread ( threading.Thread ):

   def __init__(self,matlab_command):
   self.matlab_command = matlab_command
   self.matlab_object = Dispatch('matlab.application.single')
   threading.Thread.__init__(self)

   def run(self):
   execute = getattr(self.matlab_object,'Execute')
   execute(self.matlab_command)

   def awesome_dud(self):
   execute = getattr(self.matlab_object,'Execute')
   execute(self.matlab_command)


a = MyThread('a=1:1:100')
b = MyThread('b=1:1:200')

# Running matlab function through thread (It's not working)
# =

a.start()
b.start()
a.join()
b.join()

# Running matlab function not through thread (it's working)
# =
a.awesome_dud()
b.awesome_dud()

-- 
http://mail.python.org/mailman/listinfo/python-list


Passing com object from simple xmlrpc server to client

2006-11-27 Thread tsjuan
Hello python users,

I am just learning on how to use xmlrpc and stumbled upon how to pass
com object
from server to client side.

The client side complain about can't marshall the com object. I don't
know what type
of marshall command I should use to pass the object.

Below are my scripts, any help / comments are greatly appreciated:

# Server Side script
# ===

import win32com.client
import SimpleXMLRPCServer
import pythoncom

class ServerFunctions(object):

   def call_com_object(self):
   pythoncom.CoInitialize()
   return win32com.client.Dispatch('excel.application')

if __name__ == '__main__'
server =
SimpleXMLRPCServer.SimpleXMLROCServer(('hostname',portnumber))
server.register_instance(ServerFunctions())


# Client Side Script
# ==

import xmlrpclib
client = xmlrpclib.Server('http://hostname:portname";)
excel_object = client.call_com_object()



Regards,
Tanto Sugiarto

-- 
http://mail.python.org/mailman/listinfo/python-list