def proxy_iter(self, method, *args): """ Iterable proxy for dictionary methods called over IPC pipe. """ import x84.bbs.session event = 'db=%s' % (self.schema, ) session = x84.bbs.session.getsession() session.flush_event(event) session.send_event(event, (self.table, method, args)) data = session.read_event(event) assert data == (None, 'StartIteration'), ( 'iterable proxy used on non-iterable, %r' % (data, )) data = session.read_event(event) while data != (None, StopIteration): yield data data = session.read_event(event) session.flush_event(event)
def proxy_iter(self, method, *args): """ Iterable proxy for dictionary methods called over IPC pipe. """ import x84.bbs.session event = 'db=%s' % (self.schema,) session = x84.bbs.session.getsession() session.flush_event(event) session.send_event(event, (self.table, method, args)) data = session.read_event(event) assert data == (None, 'StartIteration'), ( 'iterable proxy used on non-iterable, %r' % (data,)) data = session.read_event(event) while data != (None, StopIteration): yield data data = session.read_event(event) session.flush_event(event)
def proxy_method(self, method, *args): """ Proxy for dictionary methods called over IPC pipe. """ import x84.bbs.session event = 'db-%s' % (self.schema, ) session = x84.bbs.session.getsession() session.send_event(event, (self.table, method, args)) return session.read_event(event)
def proxy_method(self, method, *args): """ Proxy for dictionary methods called over IPC pipe. """ import x84.bbs.session event = 'db-%s' % (self.schema,) session = x84.bbs.session.getsession() session.send_event(event, (self.table, method, args)) return session.read_event(event)
def read(self): """ Reads input until ESCAPE key is pressed (Blocking). Returns None. """ from x84.bbs.session import getsession from x84.bbs.output import echo session = getsession() self._quit = False echo(self.refresh()) while not self.quit: echo(self.process_keystroke(session.read_event('input')))
def read(self): """ Reads input until the ENTER or ESCAPE key is pressed (Blocking). Allows backspacing. Returns unicode text, or None when cancelled. """ from x84.bbs.session import getsession from x84.bbs.output import echo session = getsession() self._selected = False self._quit = False echo(self.refresh()) while not (self.selected or self.quit): echo(self.process_keystroke(session.read_event('input'))) if self.quit: return None return self.selection[0]
def read(self): """ Reads input until the ENTER or ESCAPE key is pressed (Blocking). Allows backspacing. Returns unicode text, or None when cancelled. """ from x84.bbs.session import getsession from x84.bbs.output import echo session = getsession() echo(self.refresh()) self._quit = False self._carriage_returned = False while not (self.quit or self.carriage_returned): inp = session.read_event("input") echo(self.process_keystroke(inp)) if not self.quit: return self.content return None
def acquire(self, blocking=False): """ Acquire a fine-grained BBS-global lock, blocking or non-blocking. When invoked with the blocking argument set to True (the default), block until the lock is acquired, and return True. When invoked with the blocking argument set to False, do not block. Returns False if lock is not acquired. """ import x84.bbs.session event = 'lock-%s/%s' % (self.schema, self.table) session = x84.bbs.session.getsession() while True: session.send_event(event, ('acquire', True)) if session.read_event(event): return True if not blocking: return False time.sleep(0.1)
def acquire(self, blocking=True, stale=2.0): """ Acquire a fine-grained BBS-global lock, blocking or non-blocking. When invoked with the blocking argument set to True (the default), block until the lock is acquired, and return True. When invoked with the blocking argument set to False, do not block. Returns False if lock is not acquired. If the engine has held the lock longer than ``stale`` seconds, the lock is granted anyway. """ import x84.bbs.session event = 'lock-%s/%s' % (self.schema, self.table) session = x84.bbs.session.getsession() while True: session.send_event(event, ('acquire', stale)) data = session.read_event(event) if data is True or not blocking: return data time.sleep(0.1)