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

Method _pop

Lib/imaplib.py:1528–1576  ·  view source on GitHub ↗
(self, timeout, default=('', None))

Source from the content-addressed store, hash-verified

1526 return self
1527
1528 def _pop(self, timeout, default=('', None)):
1529 # Get the next response, or a default value on timeout.
1530 # The timeout arg can be an int or float, or None for no timeout.
1531 # Timeouts require a socket connection (not IMAP4_stream).
1532 # This method ignores self._duration.
1533
1534 # Historical Note:
1535 # The timeout was originally implemented using select() after
1536 # checking for the presence of already-buffered data.
1537 # That allowed timeouts on pipe connetions like IMAP4_stream.
1538 # However, it seemed possible that SSL data arriving without any
1539 # IMAP data afterward could cause select() to indicate available
1540 # application data when there was none, leading to a read() call
1541 # that would block with no timeout. It was unclear under what
1542 # conditions this would happen in practice. Our implementation was
1543 # changed to use socket timeouts instead of select(), just to be
1544 # safe.
1545
1546 imap = self._imap
1547 if imap.state != 'IDLING':
1548 raise imap.error('_pop() only works during IDLE')
1549
1550 if imap._idle_responses:
1551 # Response is ready to return to the user
1552 resp = imap._idle_responses.pop(0)
1553 if __debug__ and imap.debug >= 4:
1554 imap._mesg(f'idle _pop({timeout}) de-queued {resp[0]}')
1555 return resp
1556
1557 if __debug__ and imap.debug >= 4:
1558 imap._mesg(f'idle _pop({timeout}) reading')
1559
1560 if timeout is not None:
1561 if timeout <= 0:
1562 return default
1563 timeout = float(timeout) # Required by socket.settimeout()
1564
1565 try:
1566 imap._get_response(timeout) # Reads line, calls _append_untagged()
1567 except IMAP4._responsetimeout:
1568 if __debug__ and imap.debug >= 4:
1569 imap._mesg(f'idle _pop({timeout}) done')
1570 return default
1571
1572 resp = imap._idle_responses.pop(0)
1573
1574 if __debug__ and imap.debug >= 4:
1575 imap._mesg(f'idle _pop({timeout}) read {resp[0]}')
1576 return resp
1577
1578 def __next__(self):
1579 imap = self._imap

Callers 2

__next__Method · 0.95
burstMethod · 0.95

Calls 4

_mesgMethod · 0.80
_get_responseMethod · 0.80
errorMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected