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
benchmark.py throws SystemError #28
Comments
Not getting this behavior on Linux with those versions. Will get a Windows7 virtualbox set up to try things out. |
If you just run: |
That code runs fine. I'll investigate further, see if I can find anything useful. |
So, something interesting right off the bat.
prime just runs the benchmarks without writing any output, so we can ignore it, but an interesting thing happens when we comment out The reason for this is that by running Inside, There's some subtle race condition here, I believe, with sending to a full channel, because switching to a buffered channel with buffer size 2. |
as_deadlock raises with the original traceback as well. gevent yield_ calls are wrapped in as_deadlock, and stackless yield_ will pass. updated yield_ docstring to reflect behavior.
Ok, I've improved the behavior of as_deadlock to include the original stacktrace, and yield_ should not raise if its the last tasklet. I'll dig into this on Windows now. |
May take a while to get my Windows box set up for development... in the meantime, could you try with the tip of gevent in github?
Yes very likely. We suspect this is why the pypystackless tests don't work either. I will work through this code and see. Also going from the gevent docs, it appears libev has some problems on Windows- not just bugs but also uknown errors. There could also be some gevent->libev bugs on Windows. |
Ok so here's some progress for the morning. A bit of a mind-dump, maybe writing it out will help uncover something? I can repro easily (on Windows only) by taking the This has nothing to do with a deadlock, so I've removed the as_deadlock catch for SystemError. We are putting gevent/libev into a bad state somehow- I suspect the same thing is happening that is causing pypystackless to be in a bad state. It's the same sort of thing- symptom is that there's no runnable tasklet or whatever, but that cannot really be. Solving one may solve the other! (See #2 ) This is where it gets interesting. On my machine, I consistently fail at iteration 997. However, if instead of:
I have (you may need to import backends first):
I fail on iteration 499- which is about half of 997. Do you get the same behavior @MichaelAz , or is that just coincidence on my end? I suspect you are spot on, that the problem is send/recv to a full channel and the behavior that goes on there. The semantics are not totally clear- a blocked send will of course yield, but how about an unblocked send? I can't remember if its tested, or even defined. There are some potential problems to work through. Will keep the thread updated over the next few days. Updates:
|
…elds control or not on successful send/recv.
Okay, confirmed a few things. Basically, something that will deadlock or run perfectly well on Linux will raise on Windows:
Will exit fine on Linux, will error on Windows. I also cannot replicate in all cases, like under a test runner. I can catch the error in select and ignore it to replicate the Linux behavior on Windows. I am not sure what else I could do, and other than performance and more Windows bugs in the future, I'm not sure what else we can do. It's up to libev/gevent to fix. |
It's been a crazy week, I'll go over your updates more thoroughgly tomorow evening/friday morning. |
I'm getting the same behavior. If this is really a bug in gevent on Windows we ought to open an issue with them. But, since this is (probably) related to the pypystackless bug - perhaps we're at fault. I really don't know. |
When I dug into it, I don't think the pypystackless and gevent-windows problems are related. I think this is genuinely a bug in gevent/libev on Windows, as I was able to repro it in a purely gevent environment (see my previous comment). Regarding the links, I wish I had taken better notes. I can only find a few pages, mostly concerning gevent's switch from libevent to libev, and libev's inferior Windows support:
Specifically there was a page I cannot now find that said something like "There should be fewer unknown errors on Windows"- I think it was for gevent (a changelog?) but could have been for libev as well. |
As discussed in gevent/gevent#459, adding a call to I'm creating a PR for this, even though the solution is extremely hacky. |
Confirmed this fixed the issue on my Windows virtualbox. |
When running benchmark.py as found in master, a SystemError is raised:
would_deadlock
passes and this consistently happens at the 495 itteration (at least for me).I'm running the code on Windows 7 with the gevent backend, and gevent==1.0.1, greenlet==0.4.2.
The text was updated successfully, but these errors were encountered: