-
Notifications
You must be signed in to change notification settings - Fork 71
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
Remove all sleep calls? #2
Comments
If we used something like Trollius, we could use asyncio even on python2.7 to yield from asyncio.sleep instead. |
The tricky thing is that any code calling a coroutine has to be aware that it's a coroutine, and use the same async framework. So it's not a drop-in replacement for code with |
We just ran into this on HomeAssistant. Since we can't allow sleeps at all in main event loop (it blocks all other integrations), we check for this and throw exceptions when detected. Why is there even a delayafterclose? |
I'm not sure this actually fixable. Happy to review PRs and merge them if the PR is up to scratch. |
Ive opened a issue upstream for pipe transport. We solved this in pyserial, but this is core python. python/cpython#96229 |
We could now have an async version of this method that calls |
The problem is that the close function on the pipe is called by cython core loop. So you cant really change it to async. You can possibly postpone this code in some call_later() solution. |
That could be circumvented in principle - e.g. you could have a |
Cython issue was closed as wont fix. So must be fixed here. Can this just indicate to caller the need to wait? |
Actually i think pexpect need to make sure here: https://github.com/pexpect/pexpect/blob/2e003effe885a54a320ba0a6eb91751714bc9ad3/pexpect/_async.py#L18 To wrap the close method of ptyprocess, and make sure it is scheduled to be executed in an executor. |
There are still a number of
time.sleep()
calls, particularly inclose()
andterminate()
. This is bad for async code, because this will hog control when the event loop could be doing other things. I'd like to work out how to remove these. If that isn't possible, it should at least be marked very clearly which methods do this.The text was updated successfully, but these errors were encountered: