-
Notifications
You must be signed in to change notification settings - Fork 205
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
Assert that there is no message to receive using ApplicationCommunicator #32
Comments
Yes, we should probably have this - I won't be able to add it myself for a while though as I've got bugs to fix elsewhere. Feel free to submit a PR if you want. |
Ok, fine. What about the following? (I'm not sure about the sleep times yet. And I'd actually prefer to implement async def queue_empty(self, timeout=0.1):
if not self.output_queue.empty():
return False
if timeout <= 0.01:
await asyncio.sleep(timeout)
return self.output_queue.empty()
await asyncio.sleep(0.01)
if not self.output_queue.empty():
return False
await asyncio.sleep(timeout - 0.01)
return self.output_queue.empty()
async def queue_count(self, wait=0.1):
await asyncio.sleep(wait)
return self.output_queue.qsize() |
I'd just have one top-level function called |
I also thought about doing it that way. But as far as I understand the communicator is closed after this exception which is not what I want in some use cases... |
Ah yes, the timeout will cancel it. I still think calling it |
What do you think about having a method to assert that there is no message to receive using the
ApplicationCommunicator
?Right now I'm doing it like this (using Channels'
WebsocketCommunicator
):I'd like to have something like
Actually the
timeout
should be 0 by default. Otherwise the tests might take quite long if you have a lot of these checks.The text was updated successfully, but these errors were encountered: