zulip/requirements
Cyril Pletinckx 9afde790c6 email: Open a single SMTP connection to send email batches.
Previously the outgoing emails were sent over several SMTP
connections through the EmailSendingWorker; establishing a new
connection each time adds notable overhead.

Redefine EmailSendingWorker worker to be a LoopQueueProcessingWorker,
which allows it to handle batches of events. At the same time, persist
the connection across email sending, if possible.

The connection is initialized in the constructor of the worker
in order to keep the same connection throughout the whole process.
The concrete implementation of the consume_batch function is simply
processing each email one at a time until they have all been sent.

In order to reuse the previously implemented decorator to retry
sending failures a new method that meets the decorator's required
arguments is declared inside the EmailSendingWorker class. This
allows to retry the sending process of a particular email inside
the batch if the caught exception leaves this process retriable.

A second retry mechanism is used inside the initialize_connection
function to redo the opening of the connection until it works or
until three attempts failed. For this purpose the backoff module
has been added to the dependencies and a test has been added to
ensure that this retry mechanism works well.

The connection is closed when the stop method is called.

Fixes: #17672.
2021-04-26 17:27:22 -07:00
..
README.md requirements: Update example to match the line above. 2021-03-04 18:08:45 -08:00
common.in email: Open a single SMTP connection to send email batches. 2021-04-26 17:27:22 -07:00
dev.in requirements: Upgrade Python requirements. 2021-04-15 21:47:33 -07:00
dev.txt email: Open a single SMTP connection to send email batches. 2021-04-26 17:27:22 -07:00
docs.in docs: Capitalize Markdown consistently. 2020-08-11 10:23:06 -07:00
docs.txt requirements: Upgrade Python requirements. 2021-04-15 21:47:33 -07:00
mypy.in mypy: Use sqlalchemy-stubs. 2020-11-16 18:17:41 -08:00
mypy.txt requirements: Upgrade Python requirements. 2021-04-15 21:47:33 -07:00
pip.in requirements: Upgrade Python requirements. 2020-12-09 14:24:54 -08:00
pip.txt requirements: Upgrade Python requirements. 2021-04-15 21:47:33 -07:00
prod.in requirements: Remove unnecessary version bounds from *.in. 2019-09-23 13:23:58 -07:00
prod.txt email: Open a single SMTP connection to send email batches. 2021-04-26 17:27:22 -07:00
thumbor-dev.in requirements: Upgrade Thumbor to 7.0.0a5 on Python 3. 2020-07-06 16:09:53 -07:00
thumbor-dev.txt requirements: Upgrade Python requirements. 2021-04-15 21:47:33 -07:00
thumbor.in requirements: Upgrade Python requirements. 2021-02-10 10:15:50 -08:00
thumbor.txt requirements: Upgrade Python requirements. 2021-04-15 21:47:33 -07:00

README.md

The dependency graph of the requirements is as follows:

dev +-> prod +-> common
+
|
v
mypy,docs,pip

Of the files, only dev, prod, and mypy have been used in the install scripts directly. The rest are implicit dependencies.

Steps to update a lock file, e.g. to update ipython from 5.3.0 to latest version: 0. Remove entry for ipython==5.3.0 in dev.txt.

  1. Run ./tools/update-locked-requirements, which will generate new entries, pinned to the latest version.
  2. Increase PROVISION_VERSION in version.py.
  3. Run ./tools/provision to install the new deps and test them.
  4. Commit your changes.