本文整理汇总了Python中pythoncom._GetGatewayCount函数的典型用法代码示例。如果您正苦于以下问题:Python _GetGatewayCount函数的具体用法?Python _GetGatewayCount怎么用?Python _GetGatewayCount使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_GetGatewayCount函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testall
def testall():
dotestall()
pythoncom.CoUninitialize()
print "AXScript Host worked correctly - %d/%d COM objects left alive." % (
pythoncom._GetInterfaceCount(),
pythoncom._GetGatewayCount(),
)
示例2: test
def test(fn):
print "The main thread is %d" % (win32api.GetCurrentThreadId())
GIT = CreateGIT()
interp = win32com.client.Dispatch("Python.Interpreter")
cookie = GIT.RegisterInterfaceInGlobal(interp._oleobj_, pythoncom.IID_IDispatch)
events = fn(4, cookie)
numFinished = 0
while 1:
try:
rc = win32event.MsgWaitForMultipleObjects(events, 0, 2000, win32event.QS_ALLINPUT)
if rc >= win32event.WAIT_OBJECT_0 and rc < win32event.WAIT_OBJECT_0 + len(events):
numFinished = numFinished + 1
if numFinished >= len(events):
break
elif rc == win32event.WAIT_OBJECT_0 + len(events): # a message
# This is critical - whole apartment model demo will hang.
pythoncom.PumpWaitingMessages()
else: # Timeout
print "Waiting for thread to stop with interfaces=%d, gateways=%d" % (
pythoncom._GetInterfaceCount(),
pythoncom._GetGatewayCount(),
)
except KeyboardInterrupt:
break
GIT.RevokeInterfaceFromGlobal(cookie)
del interp
del GIT
示例3: __call__
def __call__(self, result = None):
# Always ensure we don't leak gateways/interfaces
gc.collect()
ni = _GetInterfaceCount()
ng = _GetGatewayCount()
self.real_test(result)
# Failed - no point checking anything else
if result.shouldStop or not result.wasSuccessful():
return
self._do_leak_tests(result)
gc.collect()
lost_i = _GetInterfaceCount() - ni
lost_g = _GetGatewayCount() - ng
if lost_i or lost_g:
msg = "%d interface objects and %d gateway objects leaked" \
% (lost_i, lost_g)
result.addFailure(self.real_test, (AssertionError, msg, None))
示例4: CheckClean
def CheckClean():
# Ensure no lingering exceptions - Python should have zero outstanding
# COM objects
sys.exc_clear()
c = _GetInterfaceCount()
if c:
print "Warning - %d com interface objects still alive" % c
c = _GetGatewayCount()
if c:
print "Warning - %d com gateway objects still alive" % c
示例5: __call__
def __call__(self, result = None):
# For the COM suite's sake, always ensure we don't leak
# gateways/interfaces
from pythoncom import _GetInterfaceCount, _GetGatewayCount
gc.collect()
ni = _GetInterfaceCount()
ng = _GetGatewayCount()
self.real_test(result)
# Failed - no point checking anything else
if result.shouldStop or not result.wasSuccessful():
return
self._do_leak_tests(result)
gc.collect()
lost_i = _GetInterfaceCount() - ni
lost_g = _GetGatewayCount() - ng
if lost_i or lost_g:
msg = "%d interface objects and %d gateway objects leaked" \
% (lost_i, lost_g)
exc = AssertionError(msg)
result.addFailure(self.real_test, (exc.__class__, exc, None))
示例6: CheckClean
def CheckClean():
# Ensure no lingering exceptions - Python should have zero outstanding
# COM objects
try:
sys.exc_clear()
except AttributeError:
pass # py3k
c = _GetInterfaceCount()
if c:
print("Warning - %d com interface objects still alive" % c)
c = _GetGatewayCount()
if c:
print("Warning - %d com gateway objects still alive" % c)
示例7: main
num = num + 1
finally:
win32api.RegCloseKey(key)
win32ui.DoWaitCursor(0)
ret.sort()
return ret
def main():
from pywin.tools import hierlist
root = HLIRoot("COM Browser")
if sys.modules.has_key("app"):
# do it in a window
browser.MakeTemplate()
browser.template.OpenObject(root)
else:
# list=hierlist.HierListWithItems( root, win32ui.IDB_BROWSER_HIER )
# dlg=hierlist.HierDialog("COM Browser",list)
dlg = browser.dynamic_browser(root)
dlg.DoModal()
if __name__=='__main__':
main()
ni = pythoncom._GetInterfaceCount()
ng = pythoncom._GetGatewayCount()
if ni or ng:
print "Warning - exiting with %d/%d objects alive" % (ni,ng)
示例8: len
elif medium.tymed==pythoncom.TYMED_MFPICT:
data = "METAFILE handle %d" % medium.data
elif medium.tymed==pythoncom.TYMED_ENHMF:
data = "ENHMETAFILE handle %d" % medium.data
elif medium.tymed==pythoncom.TYMED_HGLOBAL:
data = "%d bytes via HGLOBAL" % len(medium.data)
elif medium.tymed==pythoncom.TYMED_FILE:
data = "filename '%s'" % data
elif medium.tymed==pythoncom.TYMED_ISTREAM:
stream = medium.data
stream.Seek(0,0)
bytes = 0
while 1:
chunk = stream.Read(4096)
if not chunk:
break
bytes += len(chunk)
data = "%d bytes via IStream" % bytes
elif medium.tymed==pythoncom.TYMED_ISTORAGE:
data = "a IStorage"
else:
data = "*** unknown tymed!"
print " -> got", data
do = None
if __name__=='__main__':
DumpClipboard()
if pythoncom._GetInterfaceCount()+pythoncom._GetGatewayCount():
print "XXX - Leaving with %d/%d COM objects alive" % \
(pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount())
示例9: fn
events = fn(4, cookie)
numFinished = 0
while 1:
try:
rc = win32event.MsgWaitForMultipleObjects(events, 0, 2000, win32event.QS_ALLINPUT)
if rc >= win32event.WAIT_OBJECT_0 and rc < win32event.WAIT_OBJECT_0+len(events):
numFinished = numFinished + 1
if numFinished >= len(events):
break
elif rc==win32event.WAIT_OBJECT_0 + len(events): # a message
# This is critical - whole apartment model demo will hang.
pythoncom.PumpWaitingMessages()
else: # Timeout
print("Waiting for thread to stop with interfaces=%d, gateways=%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount()))
except KeyboardInterrupt:
break
GIT.RevokeInterfaceFromGlobal(cookie)
del interp
del GIT
if __name__=='__main__':
test(BeginThreadsSimpleMarshal)
win32api.Sleep(500)
# Doing CoUninit here stop Pythoncom.dll hanging when DLLMain shuts-down the process
pythoncom.CoUninitialize()
if pythoncom._GetInterfaceCount()!=0 or pythoncom._GetGatewayCount()!=0:
print("Done with interfaces=%d, gateways=%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount()))
else:
print("Done.")
示例10: AXDebugger
global currentDebugger
if currentDebugger is None:
currentDebugger = AXDebugger()
return currentDebugger
def Break():
_GetCurrentDebugger().Break()
brk = Break
set_trace = Break
def dosomethingelse():
a=2
b = "Hi there"
def dosomething():
a=1
b=2
dosomethingelse()
def test():
Break()
input("Waiting...")
dosomething()
print("Done")
if __name__=='__main__':
print("About to test the debugging interfaces!")
test()
print(" %d/%d com objects still alive" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount()))
示例11: _DoTestMarshal
def _DoTestMarshal(self, fn, bCoWait = 0):
#print "The main thread is %d" % (win32api.GetCurrentThreadId())
threads, events = fn(2)
numFinished = 0
while 1:
try:
if bCoWait:
rc = pythoncom.CoWaitForMultipleHandles(0, 2000, events)
else:
# Specifying "bWaitAll" here will wait for messages *and* all events
# (which is pretty useless)
rc = win32event.MsgWaitForMultipleObjects(events, 0, 2000, win32event.QS_ALLINPUT)
if rc >= win32event.WAIT_OBJECT_0 and rc < win32event.WAIT_OBJECT_0+len(events):
numFinished = numFinished + 1
if numFinished >= len(events):
break
elif rc==win32event.WAIT_OBJECT_0 + len(events): # a message
# This is critical - whole apartment model demo will hang.
pythoncom.PumpWaitingMessages()
else: # Timeout
print "Waiting for thread to stop with interfaces=%d, gateways=%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount())
except KeyboardInterrupt:
break
for t in threads:
t.join(2)
self.failIf(t.isAlive(), "thread failed to stop!?")
threads = None # threads hold references to args