问题描述
我想从Gmail中通过其ID提取多封邮件,为此我正在使用Imap。 直到我尝试使用ThreadPull执行器(甚至是2个执行器)加快运行速度时,它的效果都很好。
如果任何人都可以考虑导致该问题的原因,那将非常有帮助。
connector.py
def create_data_models(self,msgs_ids,max_workers=2):
data_models = []
#msgs_id_list = [message['id'] for message in messages]
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
futures = {executor.submit(self.imapService.fetch_message,msg_id) : msg_id for msg_id in msgs_ids}
for future in concurrent.futures.as_completed(futures):
try:
data = future.result()
data_model = self._create_msg_obj1(data)
data_models.append(data_model)
except Exception as exc:
print('generated an exception: %s' % (exc))
return data_models
imap_service.py
def fetch_message(self,msg_id):
_,data = self.mail.uid('fetch',msg_id,'(RFC822)')
_,mail_data = data[0]
logger.error('Succesfully fetch message from {} with {} id'.format(self.email_address,msg_id))
print('Succesfully fetch message from {} with {} id'.format(self.email_address,msg_id))
return mail_data
错误:
generated an exception: command: UID => unexpected response: b'v5oJ8jIW2KPDzS/DHMN+58yL3Q'
generated an exception: command: UID => unexpected response: b'X-Google-Smtp-Source: APXvYqwtp0c9H1jJ8uZTRW5ZBjIyNbqRgeoGUq8heUUf00uNRHW9Nvyl1dTjYZAy6ijzL29+PTL7'
generated an exception: command: UID => unexpected response: b'X-Received: by 2002:a50:9223:: with SMTP id i32mr19845429eda.40.1566127216934;'
generated an exception: command: UID => unexpected response: b' Sun,18 Aug 2019 04:20:16 -0700 (PDT)'
generated an exception: command: UID => unexpected response: b'le.com; s=arc-20160816;'
generated an exception: command: UID => unexpected response: b' h=message-id:to:sender:from:reply-to:subject:date:mime-version'
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)