MCPcopy Index your code
hub / github.com/RustPython/RustPython / __exit__

Method __exit__

Lib/imaplib.py:1487–1523  ·  view source on GitHub ↗
(self, exc_type, exc_val, exc_tb)

Source from the content-addressed store, hash-verified

1485 return self
1486
1487 def __exit__(self, exc_type, exc_val, exc_tb):
1488 imap = self._imap
1489
1490 if __debug__ and imap.debug >= 4:
1491 imap._mesg('idle done')
1492 imap.state = self._saved_state
1493
1494 # Stop intercepting untagged responses before sending DONE,
1495 # since we can no longer deliver them via iteration.
1496 imap._idle_capture = False
1497
1498 # If we captured untagged responses while the IDLE command
1499 # continuation request was still pending, but the user did not
1500 # iterate over them before exiting IDLE, we must put them
1501 # someplace where the user can retrieve them. The only
1502 # sensible place for this is the untagged_responses dict,
1503 # despite its unfortunate inability to preserve the relative
1504 # order of different response types.
1505 if leftovers := len(imap._idle_responses):
1506 if __debug__ and imap.debug >= 4:
1507 imap._mesg(f'idle quit with {leftovers} leftover responses')
1508 while imap._idle_responses:
1509 typ, data = imap._idle_responses.pop(0)
1510 # Append one fragment at a time, just as _get_response() does
1511 for datum in data:
1512 imap._append_untagged(typ, datum)
1513
1514 try:
1515 imap.send(b'DONE' + CRLF)
1516 status, [msg] = imap._command_complete('IDLE', self._tag)
1517 if __debug__ and imap.debug >= 4:
1518 imap._mesg(f'idle status: {status} {msg!r}')
1519 except OSError:
1520 if not exc_type:
1521 raise
1522
1523 return False # Do not suppress context body exceptions
1524
1525 def __iter__(self):
1526 return self

Callers

nothing calls this directly

Calls 6

lenFunction · 0.85
_mesgMethod · 0.80
_append_untaggedMethod · 0.80
_command_completeMethod · 0.80
popMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected