-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation regarding purely sync defer
- Loading branch information
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Control the way synchronous calls to defer are handled | ||
====================================================== | ||
|
||
In some cases, usually linked to multithreading (see `discussion-async-sync-defer`), you | ||
may want to defer tasks purely synchronously. This can be achieving by creating your | ||
`AiopgConnector` with ``real_sync_defer=True``:: | ||
|
||
import procrastinate | ||
|
||
app = procrastinate.App( | ||
connector=procrastinate.AiopgConnector( | ||
host="somehost", | ||
real_sync_defer=True | ||
), | ||
) | ||
|
||
This will will create a ``psycopg2.pool.ThreadedConnectionPool`` (see psycopg2 | ||
documentation__), which should fit most workflows. | ||
|
||
.. __: https://www.psycopg.org/docs/pool.html#psycopg2.pool.ThreadedConnectionPool | ||
|
||
Note: the ``ThreadedConnectionPool`` will be instanciated with mostly the same | ||
parameters as the ``aiopg.Pool``. That being said, there are small differences here and | ||
there between the two parameter sets. If you find a parameter that is not well | ||
supported, feel free to warn us through an issue__. | ||
|
||
.. __: https://github.com/peopledoc/procrastinate/issues | ||
|
||
Pros and Cons of ``real_sync_defer`` | ||
------------------------------------ | ||
|
||
Pros: | ||
|
||
- Works better with multithreaded programs | ||
- Might be a bit faster because you don't create an event loop every time | ||
|
||
Cons: | ||
|
||
- Uses its own connection pool, which will increase the total number of connections | ||
used by procrastinate. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters