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

Chore: Fix RuntimeError: ... got Future <..> attached to a different loop #979

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

abetatos
Copy link

In issue #963 I commented about the RuntimeError when trying to use TestsetGenerator.

In issue #681 you discussed that using get_event_loop() was the optimal way to solve the issue but it had a Deprecation warning.

image

In newer python versions get_event_loop() raises a RuntimeError when no event loop is active. Thus we can avoid creating unnecessary new loops that seem to be the problem that was mentioned in both issues.

I have modified the code the least possible to make it clear what I intended to, although in this setup runner could be avoided as was proposed in #689

Setup:
Ragas version: 0.1.7
Python version: Python 3.10.13

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 21, 2024
@@ -96,7 +99,6 @@ def run(self):
results = self.loop.run_until_complete(self._aresults())
finally:
self.results = results
self.loop.stop()
Copy link
Member

Choose a reason for hiding this comment

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

why did you remove this?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks a lot for putting the effort to fix this issue ❤️ 🙂

Copy link
Author

Choose a reason for hiding this comment

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

Because if you use get_event_loop from a jupyter notebook you obtain the loop of the own jupyter, thus closing it might raise some problems. There might be another solution but I thought it was the most straightforward one.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks to you for creating such an awesome library!

Choose a reason for hiding this comment

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

Because if you use get_event_loop from a jupyter notebook you obtain the loop of the own jupyter, thus closing it might raise some problems.

Thank you so much for this! 🙇‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants