pyjnius icon indicating copy to clipboard operation
pyjnius copied to clipboard

Incorrect behavior when using threading

Open jps1 opened this issue 9 years ago • 0 comments

I've run into an odd scenario where I get incorrect/inconsistent behavior using Pyjnius with the python threading library. Basically if I have multiple python threads calling into a Java library, it appears to be somewhat indeterminate which thread gets called (???). I created a minimal repro case here.

There's a global variable in the python, "partial_workaround", which basically pre-calculates a string value that I'm passing to Java, and doing so seems to mitigate (though not entirely fix) the problem. Without the workaround, I can consistently get it to fail with only 2-3 threads. With the workaround, I can push it to 50 or more threads and it often works, but still sometimes fails. And despite the fact that I called it a workaround, the type of behavior I get when it fails makes it very hard to trust any use of python threading (which makes it of much less use for my project). A fix (or even a pointer to some alternate method of usage that would be 100% reliable) would be greatly appreciated!

In case it makes any difference, I should mention, I'm using pyjnius master-branch from about a week ago, Python 2.7.7 on Windows 7.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

jps1 avatar Mar 31 '15 21:03 jps1