Skip to content

Comments

Use explicit sort key in ConcurrentExecutorListResults#716

Open
dkropachev wants to merge 1 commit intomasterfrom
fix/concurrent-executor-sort-key
Open

Use explicit sort key in ConcurrentExecutorListResults#716
dkropachev wants to merge 1 commit intomasterfrom
fix/concurrent-executor-sort-key

Conversation

@dkropachev
Copy link
Collaborator

@dkropachev dkropachev commented Feb 22, 2026

Summary

Fixes bug in response handling:

TypeError: '<' not supported between instances of 'dict' and 'list'
  • Sort results by index only via key=lambda x: x[0], avoiding unnecessary comparison of ExecutionResult namedtuples which could fail on heterogeneous result/exception types

Fixes #715

Test plan

  • Existing execute_concurrent tests cover correctness of result ordering
  • Single-line defensive change — no behavioral difference for normal operation

Sort results by index only, avoiding unnecessary comparison of
ExecutionResult namedtuples which could fail on heterogeneous
result/exception types.

Fixes #715
@dkropachev dkropachev marked this pull request as ready for review February 22, 2026 21:50
@dkropachev dkropachev requested a review from Lorak-mmk February 22, 2026 21:53
@dkropachev dkropachev self-assigned this Feb 22, 2026
Copy link

@Lorak-mmk Lorak-mmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I first sent an approve, and only then read an issue. The "problem" this fixes only happens if ids are equal. IDs can never be equal, because of how statements are generated: enumerate(iter(statements_and_params)).

This is not just some immaterial detail that could change in the future: user needs to get results in the same order they passed the requests, in order to be able to match them. This means this "bug" can never be triggered. So what problem is solved here?

@dkropachev
Copy link
Collaborator Author

I first sent an approve, and only then read an issue. The "problem" this fixes only happens if ids are equal. IDs can never be equal, because of how statements are generated: enumerate(iter(statements_and_params)).

This is not just some immaterial detail that could change in the future: user needs to get results in the same order they passed the requests, in order to be able to match them. This means this "bug" can never be triggered. So what problem is solved here?

Yuu are right, technically it is unlikely, but in some cases it happens, here is the example:
https://github.com/scylladb/python-driver/actions/runs/22284500171/job/64460379139

@Lorak-mmk
Copy link

If it happens, it indicates a more serious bug. Instead of silencing it with the fix in this PR, it needs to be fixed.
Sure, the fix here would prevent the specific exception, but it would make return value meaningless (because results would have no well-defined sort order).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ConcurrentExecutorListResults: sorted() on results may compare ExecutionResult namedtuples unnecessarily

2 participants