PyMySQL / PyMySQL/PyMySQL

Option to add a timeout for ping

Open
#1,169 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.8k
Forks
1.4k
Avg merge
5h 40m
Merged PRs (30d)
5

Description

The pymsql library currently supports a timeout for connect, reading, and writing, but there isn't a specific timeout for ping.

There's an interesting interaction between this library and a more high-level one, such as sqlalchemy. Many of the default classes for connection pools in sqlalchemy often allow for a pool_pre_ping option, which will ping the connection while checking it out of the pool. If the connection does not respond or is determined to be unconnected, then the pool will fetch a brand new connection.

Conceptually, this pre-pinging is essentially acting as a connect, however there is no way to timeout quickly if the connection is hangs or is in a bad state. One could set the read/write timeout to be low, but in practice this is difficult to do, as once a transaction is open or a connection is in use, then its reasonable to tolerate some read/write lag.

While it isn't necessarily the responsibility of this library to provide a ping that uses the connect timeout, it would be great to have an option to do so.

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start at the library's ping implementation and compare how connect, reading, and writing timeouts are handled. Review the interaction described with SQLAlchemy's pool_pre_ping option; done means callers can configure a distinct ping timeout without changing normal read/write timeout behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, python
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.