Skip to content

DOCSP-48153: Add sync vs. async content to migration page #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 3, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions source/reference/migration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ application or use case:
- Your application is simple in execution, or you prefer to avoid using asynchronous calls
in your code

- Your application relies on non-concurrent workloads or workloads with very fast
- Your application relies on serial workloads or workloads with very fast
response times

- You prefer the simplicity of synchronous logic when debugging your application
Expand Down Expand Up @@ -113,10 +113,15 @@ The following Motor method signatures behave differently in the {+driver-async+}

Motor users may experience a degradation of performance when switching to the
{+driver-async+} driver. This is due to the {+driver-async+} driver using the native

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{+driver-async+} driver. This is due to the {+driver-async+} driver using the native
{+driver-async+} driver. This is due to the {+driver-async+} driver using native

``asyncio`` library instead of thread-based executors.

Users experiencing performance slowdown should consider using synchronous {+driver-short+}
with ``async.loop.run_in_executor()`` for asynchronous compatibility. To learn more, see
``asyncio`` library instead of thread-based executors. Thread-based executors

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``asyncio`` library instead of thread-based executors. Thread-based executors
``asyncio`` tasks instead of thread-based executors. Thread-based executors

have similar performance characteristics to the synchronous driver, but slower.
This means they perform better for workloads that do not fit the preceding criteria
for the {+driver-async+} driver.

If you are experiencing performance slowdown, identify whether the {+driver-async+} driver
is necessary for your usecase. If you determine your use case is better served by
synchronous {+driver-short+}, consider using the synchronous driver
with ``asyncio.loop.run_in_executor()`` for asynchronous compatibility. To learn more, see
the `Event Loop API documentation <https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.run_in_executor>`__.

.. _pymongo-to-async-guide:
Expand Down
Loading