Lines Matching refs:self

71     def __init__(self, name):
72 self.lock = _thread.allocate_lock()
73 self.wakeup = _thread.allocate_lock()
74 self.name = name
75 self.owner = None
76 self.count = 0
77 self.waiters = 0
79 def has_deadlock(self):
82 tid = self.owner
100 def acquire(self):
107 _blocking_on[tid] = self
110 with self.lock:
111 if self.count == 0 or self.owner == tid:
112 self.owner = tid
113 self.count += 1
115 if self.has_deadlock():
116 raise _DeadlockError('deadlock detected by %r' % self)
117 if self.wakeup.acquire(False):
118 self.waiters += 1
120 self.wakeup.acquire()
121 self.wakeup.release()
125 def release(self):
127 with self.lock:
128 if self.owner != tid:
130 assert self.count > 0
131 self.count -= 1
132 if self.count == 0:
133 self.owner = None
134 if self.waiters:
135 self.waiters -= 1
136 self.wakeup.release()
138 def __repr__(self):
139 return '_ModuleLock({!r}) at {}'.format(self.name, id(self))
146 def __init__(self, name):
147 self.name = name
148 self.count = 0
150 def acquire(self):
151 self.count += 1
154 def release(self):
155 if self.count == 0:
157 self.count -= 1
159 def __repr__(self):
160 return '_DummyModuleLock({!r}) at {}'.format(self.name, id(self))
165 def __init__(self, name):
166 self._name = name
167 self._lock = None
169 def __enter__(self):
170 self._lock = _get_module_lock(self._name)
171 self._lock.acquire()
173 def __exit__(self, *args, **kwargs):
174 self._lock.release()
254 def _requires_builtin_wrapper(self, fullname):
258 return fxn(self, fullname)
265 def _requires_frozen_wrapper(self, fullname):
269 return fxn(self, fullname)
275 def _load_module_shim(self, fullname):
284 spec = spec_from_loader(fullname, self)
357 def __init__(self, name, loader, *, origin=None, loader_state=None,
359 self.name = name
360 self.loader = loader
361 self.origin = origin
362 self.loader_state = loader_state
363 self.submodule_search_locations = [] if is_package else None
364 self._uninitialized_submodules = []
367 self._set_fileattr = False
368 self._cached = None
370 def __repr__(self):
371 args = ['name={!r}'.format(self.name),
372 'loader={!r}'.format(self.loader)]
373 if self.origin is not None:
374 args.append('origin={!r}'.format(self.origin))
375 if self.submodule_search_locations is not None:
377 .format(self.submodule_search_locations))
378 return '{}({})'.format(self.__class__.__name__, ', '.join(args))
380 def __eq__(self, other):
381 smsl = self.submodule_search_locations
383 return (self.name == other.name and
384 self.loader == other.loader and
385 self.origin == other.origin and
387 self.cached == other.cached and
388 self.has_location == other.has_location)
393 def cached(self):
394 if self._cached is None:
395 if self.origin is not None and self._set_fileattr:
398 self._cached = _bootstrap_external._get_cached(self.origin)
399 return self._cached
402 def cached(self, cached):
403 self._cached = cached
406 def parent(self):
408 if self.submodule_search_locations is None:
409 return self.name.rpartition('.')[0]
411 return self.name
414 def has_location(self):
415 return self._set_fileattr
418 def has_location(self, value):
419 self._set_fileattr = bool(value)
1026 def __enter__(self):
1030 def __exit__(self, exc_type, exc_value, exc_traceback):