Commit 2fcce70
committed
pool: Handle non-shard-aware endpoints in logging
When connecting to non-shard-aware endpoints, conn.features.shard_id is None.
Previously, this would cause a TypeError when logging with %i format specifier.
```
Traceback (most recent call last):
File "/usr/lib64/python3.12/logging/__init__.py", line 1160, in emit
msg = self.format(record)
^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/logging/__init__.py", line 999, in format
return fmt.format(record)
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/_pytest/logging.py", line 136, in format
return super().format(record)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/logging/__init__.py", line 703, in format
record.message = record.getMessage()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/logging/__init__.py", line 392, in getMessage
msg = msg % self.args
~~~~^~~~~~~~~~~
TypeError: %i format: a real number is required, not NoneType
Call stack:
File "/usr/lib64/python3.12/threading.py", line 1032, in _bootstrap
self._bootstrap_inner()
File "/usr/lib64/python3.12/threading.py", line 1075, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.12/threading.py", line 1012, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib64/python3.12/concurrent/futures/thread.py", line 92, in _worker
work_item.run()
File "/usr/lib64/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
Message: 'Received a connection %s for shard_id=%i on host %s'
Arguments: (140333813254336, None, <Host: 127.67.173.34:9042 dc2>)
```
Now prints -1 as a fallback value instead of raising an exception.
This fixes logging failures that occurred when:
- Connecting to non-shard-aware endpoints
- Debug logging level was enabled
Signed-off-by: Kefu Chai <[email protected]>1 parent 1316cd1 commit 2fcce70
1 file changed
+5
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
731 | 731 | | |
732 | 732 | | |
733 | 733 | | |
734 | | - | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
735 | 739 | | |
736 | 740 | | |
737 | 741 | | |
| |||
0 commit comments