本文整理汇总了Python中win32event.CreateMutex方法的典型用法代码示例。如果您正苦于以下问题:Python win32event.CreateMutex方法的具体用法?Python win32event.CreateMutex怎么用?Python win32event.CreateMutex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32event
的用法示例。
在下文中一共展示了win32event.CreateMutex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __acquire
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import CreateMutex [as 别名]
def __acquire(self):
'''
Attempts to acquire the mutex
@raise MutexAlreadyAcquired
'''
mutex = win32event.CreateMutex(None, 1, self.MUTEX_NAME)
if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
raise MutexAlreadyAcquired()
return mutex
# ================================================================
# = MutexAlreadyAcquired Exception Class
# ===============================================================
示例2: create
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import CreateMutex [as 别名]
def create(self):
obtain_mutex = 1
mutex = win32event.CreateMutex(None, obtain_mutex, app_name)
# prevent the PyHANDLE from going out of scope, ints are fine
self.mutex = int(mutex)
mutex.Detach()
lasterror = win32api.GetLastError()
if lasterror == winerror.ERROR_ALREADY_EXISTS:
takeover = 0
try:
# if the mutex already exists, discover which port to connect to.
# if something goes wrong with that, tell us to take over the
# role of master
takeover = self.discover_sic_socket()
except:
pass
if not takeover:
raise BTFailure(_("Global mutex already created."))
self.master = 1
# lazy free port code
port_limit = 50000
while self.port < port_limit:
try:
controlsocket = self.rawserver.create_serversocket(self.port,
'127.0.0.1')
self.controlsocket = controlsocket
break
except socket.error, e:
self.port += 1
示例3: __init__
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import CreateMutex [as 别名]
def __init__(self):
obtain_mutex = False
self.mutex = win32event.CreateMutex(None, obtain_mutex, app_name)
self.lasterror = win32api.GetLastError()
示例4: __init__
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import CreateMutex [as 别名]
def __init__(self):
self.mutexname = "testmutex_{D0E858DF-985E-4907-B7FB-8D732C3FC3B9}"
self.mutex = CreateMutex(None, False, self.mutexname)
self.lasterror = GetLastError()