Open vlovich opened 5 years ago
Oh, the problem only really manifests (or at least easiest to reproduce) if I'm dumping a lot of logs continuously. The logs are generated primarily through here: loop.add_reader(fd, fd_callback) which is monitoring an external pipe for messages to handle.
Minimum reproducible test case. When running just hold the enter key.
That looks like a bug. Thanks a lot for reporting and creating this minimum test case file. That is super useful! Right now, I'm not yet sure what's going on.
I have also come across this bug and yeah, only appears when both the logs are being dumped and the prompt is exiting and entering continuously.
Line 62 is the point where the crash occurs, and I believe the cause is because the prompt is constantly exiting and entering that at a given point it might not be None but also not running.
Had a quick go at fixing this by just modifying line 60 to also check if the app is not running, like below, seems to have solved the issue.
if app is None or not app._is_running:
return ensure_future(async_func())
assert app._is_running
Testing this with the provided test case by @vlovich proves that it works. I was also playing around and changed the seconds in the loop.call_later
lines from 0.1 to 0, which of course spins the logs out much faster and without the quick fix, hitting enter ends up freezing/hanging the app completely, however with the patch, it works as expected.
I can make a pull request if this fix is all good.
@jonathanslenders Any thoughts?
Sometimes I get this exception when I enter input.
My input processing loop looks like this:
I'm dumping things to the screen via python logging module but AFAIK I don't have any threads going on. Maybe there's a bug where prompt toolkit is launching threads unnecessarily? It seems like there's a few threads doing sleeps in key_processor which seems weird (wouldn't there only be 1?) but not sure if related or expected behaviour. Is it possible I'm doing something very wrong?