POP3线程安全吗?

Is POP3 thread safe?

我使用 poplib 从我的 Gmail 中检索新邮件。

我是按以下方式做的:

server = poplib.POP3_SSL('pop.gmail.com')
# ... login with credentials

#get info about new mails (1)
emails, total_bytes = server.stat()

for i in range(emails):
    # get new mail (2)
    response = server.retr(i+1)

我想知道如果在 (1)(2) 之间 gmail 邮箱收到新邮件会怎样?

我自己尝试过,(2) 仅适用于检索有关它们的信息时的实际消息 (1),并且没有从服务器获取新消息。

这是否由 POP3 协议保证?

是的,POP3 锁定邮箱。

来自 RFC 1939:

Once the POP3 server has determined ... that the client should be given access to the
appropriate maildrop, the POP3 server then acquires an exclusive-
access lock on the maildrop, as necessary to prevent messages from
being modified or removed before the session enters the UPDATE state.