Exemplo n.º 1
0
 def cache_decoration(*args, **kw):
     now = time()
     if now > cached_data['timestamp'] + validity or (
             cached_data['val'] is None and not_null is True):
         cached_data['val'] = fn(*args, **kw)
         cached_data['timestamp'] = time()
     return cached_data['val']
Exemplo n.º 2
0
	def loop(self):
		tasks = self._tasks
		delta = self.granularity
		add = self.add
		self._running = True
		empty_list = []
		idle_since = self.ts
		while self._running:
			self.ts = time()
			if tasks and tasks[0][0] < self.ts:
				(delay, task, generator) = heappop(tasks)
				if task.timeout is not None and self.ts > task.timeout:
					log.warn('Dropped task: %s (+%s)', task, self.ts - task.timeout)
				else:
					try:
						if not task.running:
							raise StopIteration
						if not task._considered_idle:
							idle_since = self.ts
						log.info('TASK> %s', task)
						ival = generator.next()
						log.info('<TASK done in %.3ss' % (time() - self.ts))
					except StopIteration:
						continue
					if ival is not None:
						sched.add(task, ival, task._generator)
					else:
						task.running = False
			else:
				try:
					for rfd in select.select(self._rfds.keys(), empty_list, empty_list, delta)[0]:
						for r in self._rfds[rfd]:
							r()
				except select.error, v:
					if v[0] != errno.EINTR:
						raise v
				idle_value = int(self.ts - idle_since)
				if not self._idle_infos['running']:
					if self._idle_infos['threshold'] <= idle_value:
						cb = self._idle_infos['on_enter']
						if cb:
							cb()
						self._idle_infos['running'] = True
				elif idle_value < self._idle_infos['threshold']:
					if self._idle_infos['running']:
						cb = self._idle_infos['on_exit']
						if cb:
							cb()
						self._idle_infos['running'] = False
Exemplo n.º 3
0
	def __init__(self):
		self.ts = time()
		self._tasks = []
		self.granularity = 0.01
		self._rfds = collections.defaultdict((lambda : []))
		self._idle_infos = dict(threshold=10, on_enter=None, on_exit=None, running=False)
		return None
Exemplo n.º 4
0
	def cache_decoration(*args, **args):
		now = time()
		if now > cached_data['timestamp'] + validity or cached_data['val'] is None and not_null is True:
Exemplo n.º 5
0
# Review WyGui README & LICENSE files for further details.

nname: 96
n 96(None)[return cached_data['val']
]:
	i: 59(), 95()
	o: 

nname: 95
n 95(None)[]:
	i: 0&29&46(f)
	o: 96()

nname: 59
n 59(None)[cached_data['val'] = fn(*args, **kw)
cached_data['timestamp'] = time()
]:
	i: 0&29&46(t)
	o: 96()

nname: 0&29&46
n 0&29&46(now > cached_data['timestamp'] + validity or cached_data['val'] is None and not_null is True)[now = time()
]:
	i: 
	o: 59(t), 95(f)

nname: 0&29&46
n 0&29&46(None)[now = time()
if now > cached_data['timestamp'] + validity or cached_data['val'] is None and not_null is True:
	cached_data['val'] = fn(*args, **kw)
	cached_data['timestamp'] = time()
Exemplo n.º 6
0
n 316(<dummy_ex3> EXC_MATCH KeyError)[]:
	i: 299(f)
	o: 327(t), 350(f)

nname: 309
n 309(None)[]:
	i: 299(t)
	o: 356(JA)

nname: 299
n 299(<dummy_ex3> EXC_MATCH Full)[]:
	i: 250(except)
	o: 309(t), 316(f)

nname: 254
n 254(None)[ts = time() + 0.20000000000000001
mapped.post(dict(count=1, timeout=ts))
]:
	i: 250(try)
	o: 356(JA)

nname: 250
n 250(None)[]:
	i: 222&237(t)
	o: 254(try), 299(except)

nname: 222&237
n 222&237(keycode is not None and mapped is not None)[mapped = None
]:
	i: 196(), 218()
	o: 250(t), 355(f)