julien-duponchelle/python-mysql-replication

logging statement in `BinLogStreamReader.fetchone` is using logging.WARN instead logging.log

Closed this issue · 1 comments

Version

Please specify the versions you are using. Exact version numbers are preferred.

  • Pymyrepl (e.g., 1.0.2): 1.0.6
  • OS (e.g., Ubuntu 18.04): macOS Sonoma 14.3
  • Database and version (Remove unnecessary options):
    • MariaDB: 10.6

System Variables

Not relevant for this issue.

Symptoms

When setting a read_timeout parameter to the connection_settings of the BinLogStreamReader, and the timeout is actually raised, an exception is raised even though it should be ignored and continued in the fetchone call.

    binlog_event = stream.fetchone()
                   ^^^^^^^^^^^^^^^^^
  File ".../.venv/lib/python3.11/site-packages/pymysqlreplication/binlogstream.py", line 602, in fetchone
    logging.WARN(
TypeError: 'int' object is not callable

I've manually fixed it and it properly ignored the exception and reconnected on the next call.

The fix is clear and I'll open a PR shortly, this is because we call the logging level WARN.

Steps to Reproduce

Create a BinLogStreamReader with blocking=True and a connection_settings read_timeout=1 value, to trigger an timeout from reading from the database.

Expected Outcome

The timeout is ignored and we can call fetchone again.

Actual Outcome

The timeout is not ignored and an unexpected exception is raised.

Planning to Resolve

  • I plan to create a pull request to resolve this issue.
  • I don't plan to resolve this myself and would like someone else to address it.

Fixed with #608