Python pythoncom.CoUninitialize() Examples

The following are 10 code examples of pythoncom.CoUninitialize(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pythoncom , or try the search function .
Example #1
Source File: testGIT.py    From ironpython2 with Apache License 2.0 7 votes vote down vote up
def DoTestInterpInThread(cookie):
        try:
            pythoncom.CoInitialize()
            myThread = win32api.GetCurrentThreadId()
            GIT = CreateGIT()

            interp = GIT.GetInterfaceFromGlobal(cookie, pythoncom.IID_IDispatch)
            interp = win32com.client.Dispatch(interp)

            TestInterp(interp)
            interp.Exec("import win32api")
            print "The test thread id is %d, Python.Interpreter's thread ID is %d" % (myThread, interp.Eval("win32api.GetCurrentThreadId()"))
            interp = None
            pythoncom.CoUninitialize()
        except:
            traceback.print_exc() 
Example #2
Source File: leakTest.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def testall():
  dotestall()
  pythoncom.CoUninitialize()
  print "AXScript Host worked correctly - %d/%d COM objects left alive." % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount()) 
Example #3
Source File: localserver.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def serve(clsids):
	infos = factory.RegisterClassFactories(clsids)

	pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId())	
	pythoncom.CoResumeClassObjects()

	pythoncom.PumpMessages()
	
	factory.RevokeClassFactories( infos )
	
	pythoncom.CoUninitialize() 
Example #4
Source File: testMarshal.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def _doTestInThread(self, interp):
        pythoncom.CoInitialize()
        myThread = win32api.GetCurrentThreadId()

        if freeThreaded:
            interp = pythoncom.CoGetInterfaceAndReleaseStream(interp, pythoncom.IID_IDispatch)
            interp = win32com.client.Dispatch(interp)

        interp.Exec("import win32api")
        #print "The test thread id is %d, Python.Interpreter's thread ID is %d" % (myThread, interp.Eval("win32api.GetCurrentThreadId()"))
        pythoncom.CoUninitialize() 
Example #5
Source File: overview_win.py    From marsnake with GNU General Public License v3.0 5 votes vote down vote up
def get_hardware_info(response):
    pythoncom.CoInitialize()
    win32 = wmi.WMI()

    hardware = response["hardware"]

    hardware.append({Klanguage().to_ts(1011) : [get_cpu_info()]})
    #hardware.append({'Memory' : [""]})
    hardware.append({Klanguage().to_ts(1016) : get_disk_partition(win32)})
    hardware.append({Klanguage().to_ts(1017) : [get_bios_info()]})
    hardware.append({Klanguage().to_ts(1013) : get_gpu_info(win32)})
    hardware.append({Klanguage().to_ts(1012) : get_network_card_info()})

    pythoncom.CoUninitialize() 
Example #6
Source File: polling.py    From grid-control with GNU General Public License v3.0 5 votes vote down vote up
def stop(self):
        """Stop the running thread gracefully."""

        print("Stopping thread...")
        self.keep_running = False

        # Wait for the thread to stop
        self.wait()
        print("Thread stopped")

        # Uninitialize at thread stop (used for WMI in thread)
        pythoncom.CoUninitialize() 
Example #7
Source File: wmi.py    From opsbro with MIT License 5 votes vote down vote up
def get_table_where(self, tname, where={}):
        try:
            pythoncom.CoInitialize()
            c = WMI()
            f = getattr(c, tname)
            return f(**where)
        finally:
            pythoncom.CoUninitialize() 
Example #8
Source File: classes.py    From VBad with MIT License 5 votes vote down vote up
def Quit(self):
        self.excel.Quit()
        pythoncom.CoUninitialize() 
Example #9
Source File: classes.py    From VBad with MIT License 5 votes vote down vote up
def Quit(self):
        self.word.Quit()
        #self.word.Quit()
        #os.system("taskkill /im WINWORD.exe")
        pythoncom.CoUninitialize() 
Example #10
Source File: SimulationX.py    From PySimulator with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __exit__(self, _type, _value, _traceback):
		pythoncom.CoUninitialize()