]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
docs: add back lost comment and extend it with new knowledge
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 26 Mar 2022 01:32:31 +0000 (02:32 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 26 Mar 2022 01:32:31 +0000 (02:32 +0100)
psycopg/psycopg/generators.py

index dbee2b2d1501b282aacb7d7e7f2fdc34d0ef9177..5f8f967fb3bc4e36607775b8430a78de5b788c2b 100644 (file)
@@ -203,6 +203,12 @@ def copy_from(pgconn: PGconn) -> PQGen[Union[memoryview, PGresult]]:
 
 
 def copy_to(pgconn: PGconn, buffer: bytes) -> PQGen[None]:
+    # Retry enqueuing data until successful.
+    #
+    # WARNING! This can cause an infinite loop if the buffer is too large. (see
+    # ticket #255). We avoid it in the Copy object by splitting a large buffer
+    # into smaller ones. We prefer to do it there instead of here in order to
+    # do it upstream the queue decoupling the writer task from the producer one.
     while pgconn.put_copy_data(buffer) == 0:
         yield Wait.W