summaryrefslogtreecommitdiff
path: root/doc/src/advanced.rst
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2011-06-05 16:22:54 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2011-06-05 16:22:54 +0100
commit8f876d4b5d26a4e618d0cdcb2189b5ee3abf97c6 (patch)
treeef5ff2250178d2f0a937f103174ea3ae22fd2796 /doc/src/advanced.rst
parentdcc9e84a68a0aa446b924c308a81605d57965859 (diff)
downloadpsycopg2-8f876d4b5d26a4e618d0cdcb2189b5ee3abf97c6.tar.gz
Avoid a deadlock using concurrent green threads on the same connection
Use the async_cursor property to store an indication that something is running (even if it is not necessarily a cursor running the query).
Diffstat (limited to 'doc/src/advanced.rst')
-rw-r--r--doc/src/advanced.rst8
1 files changed, 3 insertions, 5 deletions
diff --git a/doc/src/advanced.rst b/doc/src/advanced.rst
index ac16ca9..c7625b1 100644
--- a/doc/src/advanced.rst
+++ b/doc/src/advanced.rst
@@ -432,11 +432,9 @@ SQLAlchemy_) to be used in coroutine-based programs.
.. warning::
Psycopg connections are not *green thread safe* and can't be used
- concurrently by different green threads. Each connection has a lock
- used to serialize requests from different cursors to the backend process.
- The lock is held for the duration of the command: if the control switched
- to a different thread and the latter tried to access the same connection,
- the result would be a deadlock.
+ concurrently by different green threads. Trying to execute more than one
+ command at time using one cursor per thread will result in an error (or a
+ deadlock on versions before 2.4.2).
Therefore, programmers are advised to either avoid sharing connections
between coroutines or to use a library-friendly lock to synchronize shared