trinodb / trinodb/trino-python-client

Improve cursor close and connection close behaviour

Open
#529 1 comment 0 reactions 1 assignee View on GitHub

@damian3031 is already working on this.

Since Feb 27, 2025.

enhancement
Dominant language
Python
Stars
439
Forks
206
PR merge metrics
No merged PRs in 30d

Description

From https://github.com/trinodb/trino-python-client/pull/405#issuecomment-1705226919

In my head the logic should be:

  • On cursor.close()
    • Cancel any already executing queries if they exist
    • Perform implicit ROLLBACK if within a transaction
    • Set some boolean so that calling any method of the cursor leads to Error

We don't do steps 2 and 3 here (both required by DB-API).

  • On cursor.cancel() - this is not a DB-API specified method so the behaviour is up to us to specify
    • Cancel any already executing queries
      • If query already finished, return False
      • If query is running and was cancelled successfully, return True
      • If no query was executed at all (how to differentiate between this and already finished? - presence of query on the cursor?) then raise Exception

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.