Asynchronous DBAPI

Pool can support it. Users don’t need to check another connection out and call new_con.kill(another_con.thread_id) manually. Pool may do it automatically instead. So there are no boilerplate code in applications.

  • When another connection is not required to cancel a running query, DB-API driver can support it directly.
  • When another connection is necessary to cancel a running query, DB-API driver may not support automatic canceling. Canceling a running query is implemented in Pool instead.

If we need to standardize it in async DB-API, these APIs should be added:

  • Query that the driver supports automatic canceling a query. It may be similar to the threadsafe attribute. (Options are: No, Yes, Yes (but uses another connection))
  • Option to enable/disable automatic cancellation. (autocancel=False)
  • API to cancel the query executed from another connection. (e.g. Connection.kill(token))
  • API to get some “token” (query token, or connection token) to cancel the query from another connection. (e.g. cursor.kill_token())

But I’m not so interested in autocancelling. We have some production applications in Go and Python and live without autocancelling.