Async query cancellation raises AttributeError on Python 3.10 when adding an exception note
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 78/100
Piste de recherche
Lisez FluxCsvParser._parse_flux_response_async et la gestion des exceptions autour de e.add_note(...) ; l’issue identifie ce chemin comme celui qui échoue. Exécutez tests/test_FluxCSVParser.py avec Python 3.10, puis vérifiez que les exceptions d’annulation et de délai d’attente restent intactes pendant la fermeture de la réponse. Le travail est terminé lorsque les tests du parseur réussissent et que les méthodes publiques de requête asynchrones annulées propagent CancelledError.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Specifications
- Client: latest PyPI release
1.50.0, also currentmaster(be9aa4bf142be1a990bda061b56d581d753b23c8,1.51.0dev0) - Python: CPython 3.10.12 on Linux. CPython 3.13.18 is a working control.
- InfluxDB: not required. The reproduction uses a local aiohttp HTTP endpoint to send valid annotated CSV and then hold the response open.
Problem
Cancelling a task while an async query consumes CSV raises AttributeError instead of preserving asyncio.CancelledError on Python 3.10. The exception handler in FluxCsvParser._parse_flux_response_async calls e.add_note(...) unconditionally, but that method is not available on Python 3.10. The package still declares Python >=3.7 support.
This affects cancellation through query, query_stream, query_data_frame, and query_data_frame_stream. Code expecting cancellation to propagate receives an ordinary exception instead, which changes cancellation/shutdown control flow.
Reproduction
Install influxdb-client[async]==1.50.0 and pandas in a Python 3.10 environment, then run this standalone script. It uses synthetic credentials and loopback HTTP only.
import asyncio
import json
import sys
from aiohttp import web
from influxdb_client.client.influxdb_client_async import InfluxDBClientAsync
CSV = b'#datatype,string,long,double\n#group,false,false,false\n#default,_result,,\n,result,table,_value\n,,0,1.5\n'
async def case(method, mode):
started = asyncio.Event()
finish = asyncio.Event()
async def handler(request):
await request.read()
response = web.StreamResponse(headers={'Content-Type': 'text/csv'})
await response.prepare(request)
await response.write(CSV)
started.set()
await finish.wait()
return response
app = web.Application()
app.router.add_post('/api/v2/query', handler)
runner = web.AppRunner(app)
await runner.setup()
site = web.TCPSite(runner, '127.0.0.1', 0)
await site.start()
port = site._server.sockets[0].getsockname()[1]
try:
async with InfluxDBClientAsync(url=f'http://127.0.0.1:{port}', token='synthetic', org='test', timeout=100 if mode == 'timeout' else 5000) as client:
async def consume():
result = await getattr(client.query_api(), method)('synthetic query')
if hasattr(result, '__aiter__'):
async for item in result:
pass
task = asyncio.create_task(consume())
await asyncio.wait_for(started.wait(), 2)
await asyncio.sleep(0.02)
if mode == 'cancel':
task.cancel()
elif mode == 'complete':
finish.set()
try:
await task
outcome = 'completed'
except BaseException as error:
outcome = type(error).__name__
expected = {'cancel': 'CancelledError', 'timeout': 'TimeoutError', 'complete': 'completed'}[mode]
return {'method': method, 'mode': mode, 'outcome': outcome, 'expected': expected, 'pass': outcome == expected}
finally:
finish.set()
await runner.cleanup()
async def main():
results = []
for method in ('query', 'query_stream', 'query_data_frame', 'query_data_frame_stream'):
for mode in ('cancel', 'complete'):
result = await case(method, mode)
results.append(result)
print(json.dumps(result), flush=True)
print(json.dumps({'python': sys.version, 'passed': sum(r['pass'] for r in results), 'total': len(results)}))
asyncio.run(main())
Expected behavior
All four cancelled calls propagate CancelledError; all four completed-response controls succeed.
Actual behavior
On Python 3.10, each cancellation produces AttributeError; completed responses succeed. The same result occurs on release 1.50.0 and current master. On Python 3.13, all four cancellations preserve CancelledError and all completion controls succeed.
Additional checks
- A direct parser test injecting a
CancelledErrororasyncio.TimeoutErrorreproduces exception replacement on Python 3.10. An injectedValueErroris propagated unchanged, and the response is closed in all three cases. All three exceptions are preserved on Python 3.13. - The existing
tests/test_FluxCSVParser.pysuite passes unchanged: 26 tests on each Python version. - A private guard around the optional note call preserves both injected exception identities on Python 3.10 and restores all four public-API cancellation cases without changing the completed-response controls; the same 26 native parser tests still pass. No PR is included here.
This report is specifically about the Python-version compatibility regression in exception annotation introduced by #679, not about whether large queries should time out or about the earlier #671 query-size report. Timer expiry in the loopback setup still surfaces the existing cancellation behavior on newer Python; this report does not claim to fix or redefine that separate behavior.
AI assistance was used to investigate and run these synthetic reproductions. No production application or production InfluxDB instance is involved.
- Langage dominant
- Python
- Étoiles
- 796
- Forks
- 191
- Merge moyen
- 12 j 13 h
- PR mergées (30 j)
- 5
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Aucun guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de influxdata/influxdb-client-python
-
Pandas outputs warning when calling dataframe.append in flux_csv_parser._prepare_data_framePeut-être pris @dave-cz l’a pris il y a 451 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
influxdata/influxdb-client-python#613 · 7 commentaires ·
-
bug
Difficulté 3/5 1-2 jours Accessibilité débutants 30/100
influxdata/influxdb-client-python#693 · 2 commentaires · 1 réaction ·
-
Socks proxy supportOuverte
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
-
bug
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 45/100
Toutes les issues de influxdata/influxdb-client-python
Issues similaires
-
Quick Installation step 2 installs from the plugin manager, but the plugin isn't published yetOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
jenkinsci/user-guide-ai-chatbot-plugin#132 ·
Les mainteneurs répondent en général sous 6 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
gh-sync ship audits cards before writing station done, so every ship reports false STATUS findingsOuverteharness
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
mruangutai/harness#2455 ·
Les mainteneurs répondent en général sous 1 jour
-
stripthink leaves thinking text in place when the chat template opens the think tag in the promptPeut-être pris @MaiAditya l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
Les mainteneurs répondent en général sous 1 jour
-
xcorr sizes its bin array from the largest observed m/z, so one out-of-range peak kills the runPeut-être pris @BioGeek l’a pris aujourd’hui. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
instadeepai/winnow#312 ·