Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def add(self, t):
with self._lock:
self._add_timer(t)
if self.sleeping:
self.sleeping = False
taskwakeup(self._timerproc)
if self._timerproc is None or not self._timerproc.alive:
self._timerproc = tasklet(self.timerproc)()
def switch(self):
if not self.running:
self._runtask = tasklet(self.run)()
getcurrent().remove()
self._runtask.switch()
def __init__(self):
# define the main tasklet
self._main_coroutine = _coroutine_getmain()
self._main_tasklet = _coroutine_getcurrent()
self._main_tasklet.__class__ = tasklet
six.get_method_function(self._main_tasklet._init)(self._main_tasklet,
label='main')
self._last_task = self._main_tasklet
self.thread_id = thread_ident() # the scheduler thread id
self._lock = threading.Lock() # global scheduler lock
self._callback = None # scheduler callback
self._run_calls = [] # runcalls. (tasks where run apply
self.runnable = deque() # runnable tasks
self.blocked = 0 # number of blocked/sleeping tasks
self.append(self._main_tasklet)
def __init__(self):
self.loop = pyuv.Loop()
self._async = pyuv.Async(self.loop, self._wakeloop)
self._async.unref()
self.fds = {}
self._lock = threading.RLock()
self.running = False
# start the server task
self._runtask = tasklet(self.run, "uv_server")()