Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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] = {}
Ejemplo n.º 4
0
 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()
Ejemplo n.º 5
0
 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()
Ejemplo n.º 6
0
 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()
Ejemplo n.º 7
0
 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()
Ejemplo n.º 8
0
Archivo: base.py Proyecto: dadbob/pymap
 def new_events(self, n=1):
     if n == 1:
         return subsystem.get().new_event()
     else:
         return (subsystem.get().new_event() for _ in range(n))
Ejemplo n.º 9
0
 def _exec(self, future: Awaitable[_Ret]) -> Awaitable[_Ret]:
     return subsystem.get().execute(future)
Ejemplo n.º 10
0
 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] = {}
Ejemplo n.º 11
0
 def _exec(self, future: Awaitable[_Ret]) -> Awaitable[_Ret]:
     return subsystem.get().execute(future)
Ejemplo n.º 12
0
Archivo: base.py Proyecto: icgood/pymap
 def new_events(self, n=1):
     if n == 1:
         return subsystem.get().new_event()
     else:
         return (subsystem.get().new_event() for _ in range(n))