def __init__(self, ZSP):
'Initialize the Query/Reply Protocol object.'
self.__ZSP = ZSP
self.__error = None
self.__Q_anchor = []
self.__Q_packet = []
self.__R_anchor = {}
self.__Q_lock = _thread.allocate_lock()
self.__R_lock = _thread.allocate_lock()
_thread.start_new_thread(self.__thread, ())
python类allocate_lock()的实例源码
def recv_R(self, ID, timeout=None):
'Receive one reply.'
if self.__error:
raise self.__error
if timeout is not None:
if not isinstance(timeout, (float, int, long)):
raise TypeError, 'timeout must be of type float, int, or long'
if not timeout >= 0:
raise ValueError, 'timeout must be greater than or equal to 0'
anchor = [_thread.allocate_lock()]
anchor[0].acquire()
self.__R_lock.acquire()
try:
try:
self.__R_anchor[ID] = anchor
finally:
self.__R_lock.release()
except AttributeError:
raise self.__error
if timeout:
_thread.start_new_thread(self.__R_thread, (timeout, ID))
anchor[0].acquire()
try:
R = anchor[1]
except IndexError:
if self.__error:
raise self.__error
raise Warning
return R
def __init__(self, QRP):
'Initialize the Query/Reply Interface object.'
self.__QRP = QRP
self.__ID = 0
self.__lock = _thread.allocate_lock()
def __init__(self, maxsize=0, priorities = standard_priorities, realtime = 1, idle = 1):
"""Initialize a queue object with a given maximum size.
If maxsize is <= 0, the queue size is infinite.
priorities: a dictionary with definition of priorities
"""
assert self._check_priorities(priorities) #check only if not -OO
import thread
self._init(priorities, maxsize, realtime, idle)
self.mutex = thread.allocate_lock()
self.esema = thread.allocate_lock()
self.esema.acquire()
self.fsema = thread.allocate_lock()
def __init__(self, *pipes):
self.active_pipes = set()
self.active_sources = set()
self.active_drains = set()
self.active_sinks = set()
self._add_pipes(*pipes)
self.thread_lock = thread.allocate_lock()
self.command_lock = thread.allocate_lock()
self.__fdr,self.__fdw = os.pipe()
self.threadid = None
def __init__(self, raw, buffer_size=DEFAULT_BUFFER_SIZE):
"""Create a new buffered reader using the given readable raw IO object.
"""
if not raw.readable():
raise IOError('"raw" argument must be readable.')
_BufferedIOMixin.__init__(self, raw)
if buffer_size <= 0:
raise ValueError("invalid buffer size")
self.buffer_size = buffer_size
self._reset_read_buf()
self._read_lock = Lock()
def __init__(self, raw,
buffer_size=DEFAULT_BUFFER_SIZE, max_buffer_size=None):
if not raw.writable():
raise IOError('"raw" argument must be writable.')
_BufferedIOMixin.__init__(self, raw)
if buffer_size <= 0:
raise ValueError("invalid buffer size")
if max_buffer_size is not None:
warnings.warn("max_buffer_size is deprecated", DeprecationWarning,
self._warning_stack_offset)
self.buffer_size = buffer_size
self._write_buf = bytearray()
self._write_lock = Lock()
def allocate_lock():
"""Dummy implementation of thread.allocate_lock()."""
return LockType()
def __init__(self, filename, type):
self.type = type
self.filename = filename
if self.filename:
self.db = None
else:
self.db = {}
self.lock = thread.allocate_lock()
def __init__(self, mod_name = '__main__', launch_file = None):
ReplBackend.__init__(self)
self.launch_file = launch_file
self.mod_name = mod_name
self.km = VsKernelManager()
if is_ipython_versionorgreater(0, 13):
# http://pytools.codeplex.com/workitem/759
# IPython stopped accepting the ipython flag and switched to launcher, the new
# default is what we want though.
self.km.start_kernel(**{'extra_arguments': self.get_extra_arguments()})
else:
self.km.start_kernel(**{'ipython': True, 'extra_arguments': self.get_extra_arguments()})
self.km.start_channels()
self.exit_lock = thread.allocate_lock()
self.exit_lock.acquire() # used as an event
self.members_lock = thread.allocate_lock()
self.members_lock.acquire()
self.km.shell_channel._vs_backend = self
self.km.stdin_channel._vs_backend = self
if is_ipython_versionorgreater(1, 0):
self.km.iopub_channel._vs_backend = self
else:
self.km.sub_channel._vs_backend = self
self.km.hb_channel._vs_backend = self
self.execution_count = 1
visualstudio_py_testlauncher.py 文件源码
项目:pythonVSCode
作者: DonJayamanne
项目源码
文件源码
阅读 26
收藏 0
点赞 0
评论 0
def __init__(self, socket, callback):
self.socket = socket
self.seq = 0
self.callback = callback
self.lock = thread.allocate_lock()
# start the testing reader thread loop
self.test_thread_id = thread.start_new_thread(self.readSocket, ())
def __init__(self):
self.default_mode = BREAK_MODE_UNHANDLED
self.break_on = { }
self.handler_cache = dict(self.BUILT_IN_HANDLERS)
self.handler_lock = thread.allocate_lock()
self.add_exception('exceptions.IndexError', BREAK_MODE_NEVER)
self.add_exception('builtins.IndexError', BREAK_MODE_NEVER)
self.add_exception('exceptions.KeyError', BREAK_MODE_NEVER)
self.add_exception('builtins.KeyError', BREAK_MODE_NEVER)
self.add_exception('exceptions.AttributeError', BREAK_MODE_NEVER)
self.add_exception('builtins.AttributeError', BREAK_MODE_NEVER)
self.add_exception('exceptions.StopIteration', BREAK_MODE_NEVER)
self.add_exception('builtins.StopIteration', BREAK_MODE_NEVER)
self.add_exception('exceptions.GeneratorExit', BREAK_MODE_NEVER)
self.add_exception('builtins.GeneratorExit', BREAK_MODE_NEVER)
def __init__(self, id = None):
if id is not None:
self.id = id
else:
self.id = thread.get_ident()
self._events = {'call' : self.handle_call,
'line' : self.handle_line,
'return' : self.handle_return,
'exception' : self.handle_exception,
'c_call' : self.handle_c_call,
'c_return' : self.handle_c_return,
'c_exception' : self.handle_c_exception,
}
self.cur_frame = None
self.stepping = STEPPING_NONE
self.unblock_work = None
self._block_lock = thread.allocate_lock()
self._block_lock.acquire()
self._block_starting_lock = thread.allocate_lock()
self._is_blocked = False
self._is_working = False
self.stopped_on_line = None
self.detach = False
self.trace_func = self.trace_func # replace self.trace_func w/ a bound method so we don't need to re-create these regularly
self.prev_trace_func = None
self.trace_func_stack = []
self.reported_process_loaded = False
self.django_stepping = None
self.is_sending = False
# stackless changes
if stackless is not None:
self._stackless_attach()
if sys.platform == 'cli':
self.frames = []
def __init__(self):
self.lock = thread.allocate_lock()
def __init__(self, id = None):
if id is not None:
self.id = id
else:
self.id = thread.get_ident()
self._events = {'call' : self.handle_call,
'line' : self.handle_line,
'return' : self.handle_return,
'exception' : self.handle_exception,
'c_call' : self.handle_c_call,
'c_return' : self.handle_c_return,
'c_exception' : self.handle_c_exception,
}
self.cur_frame = None
self.stepping = STEPPING_NONE
self.unblock_work = None
self._block_lock = thread.allocate_lock()
self._block_lock.acquire()
self._block_starting_lock = thread.allocate_lock()
self._is_blocked = False
self._is_working = False
self.stopped_on_line = None
self.detach = False
self.trace_func = self.trace_func # replace self.trace_func w/ a bound method so we don't need to re-create these regularly
self.prev_trace_func = None
self.trace_func_stack = []
self.reported_process_loaded = False
self.django_stepping = None
self.is_sending = False
# stackless changes
if stackless is not None:
self._stackless_attach()
if sys.platform == 'cli':
self.frames = []
def __init__(self):
self.lock = thread.allocate_lock()
def __init__(self):
self.lock = thread.allocate_lock()
def __init__ (self, logger = None):
r, w = os.pipe()
self.trigger = w
self.logger = logger
asyncore.file_dispatcher.__init__ (self, r)
self.lock = _thread.allocate_lock()
self.thunks = []
def __init__ (self, logger = None):
self.logger = logger
sock_class = socket.socket
a = sock_class (socket.AF_INET, socket.SOCK_STREAM)
w = sock_class (socket.AF_INET, socket.SOCK_STREAM)
try:
a.setsockopt(
socket.SOL_SOCKET, socket.SO_REUSEADDR,
a.getsockopt(socket.SOL_SOCKET,
socket.SO_REUSEADDR) | 1
)
except socket.error:
pass
# tricky: get a pair of connected sockets
a.bind (self.address)
a.listen (1)
w.setblocking (0)
try:
w.connect (self.address)
except:
pass
r, addr = a.accept()
a.close()
w.setblocking (1)
self.trigger = w
asyncore.dispatcher.__init__ (self, r)
self.lock = _thread.allocate_lock()
self.thunks = []
self._trigger_connected = 0
def __init__(self):
"""
Most important init method
"""
self.events = []
self.mode = "m"
self.proxy = xmlrpclib.ServerProxy("http://localhost:20757")
self.lock = thread.allocate_lock()
self.event_to_send = -1