async def idle(self, state: ConnectionState, cmd: IdleCommand) -> Response: response = await self._exec(state.do_command(cmd)) if not isinstance(response, ResponseOk): return response await self.write_response(ResponseContinuation(b'Idling.')) done = subsystem.get().new_event() updates_task = asyncio.create_task( self.handle_updates(state, done, cmd)) done_task = asyncio.create_task(self.read_idle_done(cmd)) updates_exc: Optional[Exception] = None done_exc: Optional[Exception] = None try: ok = await done_task except Exception as exc: done_exc = exc finally: done.set() try: await updates_task except Exception as exc: updates_exc = exc if updates_exc: raise updates_exc elif done_exc: raise done_exc elif not ok: return ResponseBad(cmd.tag, b'Expected "DONE".') else: return response
async def idle(self, state: ConnectionState, cmd: IdleCommand) \ -> CommandResponse: response = await self._exec(state.do_command(cmd)) if not isinstance(response, ResponseOk): return response await self.write_response(ResponseContinuation(b'Idling.')) done = subsystem.get().new_event() updates_task = asyncio.create_task( self.handle_updates(state, done, cmd)) done_task = asyncio.create_task(self.read_idle_done(cmd)) updates_exc: Optional[Exception] = None done_exc: Optional[Exception] = None try: ok = await done_task except Exception as exc: done_exc = exc finally: done.set() try: await updates_task except Exception as exc: updates_exc = exc if updates_exc: raise updates_exc elif done_exc: raise done_exc elif not ok: return ResponseBad(cmd.tag, b'Expected "DONE".') else: return response
def __init__(self) -> None: super().__init__() self._content_cache = _ContentCache() self._thread_cache = _ThreadCache() self._inbox = MailboxData(self._content_cache, self._thread_cache) self._set: Dict[str, MailboxData] = OrderedDict() self._set_lock = subsystem.get().new_rwlock() self._subscribed: Dict[str, bool] = {}
def __init__(self) -> None: self._guid = self._new_guid() self._readonly = False self._messages_lock = subsystem.get().new_rwlock() self._selected_set = SelectedSet() self._uid_validity = MailboxSnapshot.new_uid_validity() self._max_uid = 100 self._mod_sequences = _ModSequenceMapping() self._messages: Dict[int, Message] = OrderedDict()
def __init__(self, guid: bytes, maildir: Maildir, path: str) -> None: super().__init__() self._guid = guid self._maildir = maildir self._path = path self._uid_validity = 0 self._next_uid = 0 self._flags: Optional[MaildirFlags] = None self._messages_lock = subsystem.get().new_rwlock() self._selected_set = SelectedSet()
def __init__(self, mailbox_id: ObjectId, maildir: Maildir, path: str) -> None: super().__init__() self._mailbox_id = mailbox_id self._maildir = maildir self._path = path self._uid_validity = 0 self._next_uid = 0 self._flags: Optional[MaildirFlags] = None self._messages_lock = subsystem.get().new_rwlock() self._selected_set = SelectedSet()
def __init__(self, content_cache: _ContentCache, thread_cache: _ThreadCache) -> None: self._mailbox_id = ObjectId.random_mailbox_id() self._content_cache = content_cache self._thread_cache = thread_cache self._readonly = False self._messages_lock = subsystem.get().new_rwlock() self._selected_set = SelectedSet() self._uid_validity = MailboxSnapshot.new_uid_validity() self._max_uid = 100 self._mod_sequences = _ModSequenceMapping() self._messages: Dict[int, Message] = OrderedDict()
def new_events(self, n=1): if n == 1: return subsystem.get().new_event() else: return (subsystem.get().new_event() for _ in range(n))
def _exec(self, future: Awaitable[_Ret]) -> Awaitable[_Ret]: return subsystem.get().execute(future)
def __init__(self) -> None: super().__init__() self._inbox = MailboxData() self._set: Dict[str, 'MailboxData'] = OrderedDict() self._set_lock = subsystem.get().new_rwlock() self._subscribed: Dict[str, bool] = {}