Copy task that writes two rows with controlled pauses.
()
| 969 | execution_log = [] |
| 970 | |
| 971 | def copy_task(): |
| 972 | """Copy task that writes two rows with controlled pauses.""" |
| 973 | cur = conn.cursor() |
| 974 | with cur.copy("copy copy_concurrency_test from stdin") as copy: |
| 975 | # Pause after entering copy context |
| 976 | execution_log.append("entered_copy") |
| 977 | copy_entered.set() |
| 978 | can_proceed.wait() |
| 979 | |
| 980 | # Write first row and pause |
| 981 | copy.write_row((1, "first")) |
| 982 | execution_log.append("wrote_row_1") |
| 983 | wrote_first.set() |
| 984 | can_proceed.wait() |
| 985 | |
| 986 | # Write second row and pause |
| 987 | copy.write_row((2, "second")) |
| 988 | execution_log.append("wrote_row_2") |
| 989 | wrote_second.set() |
| 990 | can_proceed.wait() |
| 991 | |
| 992 | # Copy context exited, lock should now be released |
| 993 | execution_log.append("exited_copy") |
| 994 | |
| 995 | def worker_task(): |
| 996 | """ |