Hi, I'm hoping that someone can help with this... I've seen some old posts which I think may refer to this same issue but I'm having difficulty understanding how to come up with a solution, and particularly where any "PumpWaitingMessages" should be located and/or/how/whether pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) should be used.
The code processes data for 25/30 messages received back from the com object but then seems to jump back to the 'if __name__ == '__main__' and passes that same parameter (originally passed from the command line) and runs all over again... The process is intended to: 1. pass a parameter from the command line 2. open a [pickle] file to store the data 3. call a COM object with Dispatch events (to an EventHandler) 4. for each block of data received back into the EventHandler, drop it into the pickle 5. close the pickle file I'd be immensely grateful for any assistance you can give. Rob Essentially the skeleton code I have (and I hope it's intelligible) is as follows: if __name__ == '__main__': arg = sys.argv[1:] proc(arg[0]) def proc(arg): fh = file("thispickle.pkl", 'wb') x = Async(arg) # see below fh.close() [in a seperate module I have the following construct for the Dispatch] class EventHandler: def onData(self, event): # do stuff with data in 'event' cPickle.dump(data, self.fh) # flag this as 'done' class Async: def __init__(self, params): #pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) # should this go here?? s = win32com.client.DispatchWithEvents('com_obj' , EventHandler) self.finished = False while not self.finished: PumpWaitingMessages() if messages_all_flagged: self.finished = True
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32