Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Convert Clock.sleep to async. #8215

Closed
wants to merge 2 commits into from
Closed

Convert Clock.sleep to async. #8215

wants to merge 2 commits into from

Conversation

clokep
Copy link
Member

@clokep clokep commented Aug 31, 2020

This converts Clock.sleep to async.

I removed some sleep calls in the tests without ill effect, but I'm not 100% sure that removing them is OK. (Although if the tests still pass it kind of implies that they were either not necessary or that the tests isn't testing what we hope it is.)

@clokep clokep mentioned this pull request Aug 31, 2020
48 tasks
@clokep clokep requested a review from a team August 31, 2020 19:47
@@ -109,7 +109,9 @@ def testfunc():
def test_run_in_background_with_coroutine(self):
async def testfunc():
self._check_test_key("one")
d = Clock(reactor).sleep(0)
# Theoretically the ensureDeferred shouldn't be necessary here, but
# it forces trial to fire the awaitable.
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, can you expand on this a bit? I don't really understand what you mean by "fire"?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think in order to get Twisted to actually run the sleep call it needs to be wrapped in ensureDeferred?

That doesn't really seem right though since the run_in_background call in _test_run_in_background should handle that.

Without this change it was hanging on the await d call below.

@clokep clokep self-assigned this Sep 3, 2020
@clokep
Copy link
Member Author

clokep commented Sep 9, 2020

I'm going to close this for now, I think it is causing some odd interaction between the reactor and the asyncio code, but I haven't seen this causing any issues while attempting to profile so hopefully it is fine.

@clokep clokep closed this Sep 9, 2020
@clokep clokep deleted the clokep/async-clock branch October 20, 2020 17:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants