MCPcopy
hub / github.com/psycopg/psycopg / copy_task

Function copy_task

tests/test_copy_async.py:990–1012  ·  view source on GitHub ↗

Copy task that writes two rows with controlled pauses.

()

Source from the content-addressed store, hash-verified

988 execution_log = []
989
990 async def copy_task():
991 """Copy task that writes two rows with controlled pauses."""
992 cur = aconn.cursor()
993 async with cur.copy("copy copy_concurrency_test from stdin") as copy:
994 # Pause after entering copy context
995 execution_log.append("entered_copy")
996 copy_entered.set()
997 await can_proceed.wait()
998
999 # Write first row and pause
1000 await copy.write_row((1, "first"))
1001 execution_log.append("wrote_row_1")
1002 wrote_first.set()
1003 await can_proceed.wait()
1004
1005 # Write second row and pause
1006 await copy.write_row((2, "second"))
1007 execution_log.append("wrote_row_2")
1008 wrote_second.set()
1009 await can_proceed.wait()
1010
1011 # Copy context exited, lock should now be released
1012 execution_log.append("exited_copy")
1013
1014 async def worker_task():
1015 """

Callers

nothing calls this directly

Calls 5

cursorMethod · 0.45
copyMethod · 0.45
setMethod · 0.45
waitMethod · 0.45
write_rowMethod · 0.45

Tested by

no test coverage detected