Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support keyboard interrupt in Python #1438

Merged
merged 3 commits into from
Oct 23, 2023

Conversation

wjones127
Copy link
Contributor

Closes #1436.

Comment on lines 469 to 487
def test_keyboard_interrupt(tmp_path, dataset):
assert not dataset.has_index
ann_ds = lance.write_dataset(dataset.to_table(), tmp_path / "indexed.lance")

try:
start_time = time.monotonic()

# Create an index in a thread
thread = Thread(target=ann_ds.create_index, args=("vector"), kwargs=dict(
index_type="IVF_PQ",
num_partitions=4,
num_sub_vectors=16,
))

raise KeyboardInterrupt()
except KeyboardInterrupt:
end_time = time.monotonic()

assert end_time - start_time < 0.2
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of testing at this level you could potentially write a unit test in executor.rs that takes an endless dummy task (async sleep in a loop) and then make sure you can interrupt it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eh I give up on testing this for now. I've confirmed manually this allows keyboard interrupt, and is especially handy for the create index part.

@wjones127 wjones127 marked this pull request as ready for review October 19, 2023 22:24
@wjones127 wjones127 changed the title feat: suport keyboard interrupt feat: support keyboard interrupt in Python Oct 19, 2023
@wjones127 wjones127 merged commit 6076702 into main Oct 23, 2023
10 checks passed
@wjones127 wjones127 deleted the wjones127/keyboard-interrupt branch October 23, 2023 20:46
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.

Rust code doesn't respect SIGINT signal
3 participants