- Notifications
You must be signed in to change notification settings - Fork 30
Rebase to pythonnet master#20
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
still need to look at windows case
* fixed bug of method PyString_FromString * fixup! fixed bug of method PyString_FromString * removed spaces * Update appveyor.yml * Update requirements.txt * Update conversiontest.cs * Update test_conversion.py
Travis now has msbuild 15 available, which breaks the no-arg build since it's using the pythonnet.sln which is msbuild 14. Fixed by forcing the use of msbuild 14. Appveyor on py34 is failing to build psutil; newer python and py27 are using binary releases so the problem doesn't show up. I couldn't figure out how to fix it, so I made it an allowed failure.
The Unity editor unloads the C# domain and creates a new domain every time it recompiles C# sources. This caused two crashes. 1. After a domain unload, python is now pointing to a bunch of objects whose C# side is now garbage. Solution: Shutdown() the engine on domain reload, which calls Py_Finalize. 2. After a domain unload, Py_Finalize, and a new Py_Intialize, python still keeps pointers in gc for any python objects that were leaked. And pythonnet leaks. This means that python's gc will be calling tp_traverse, tp_clear, and tp_is_gc on types that are implemented in C#. This crashes because the implementation was freed. Solution: implement those calls in code that is *not* released on domain unload. Side effect: we leak a page on every domain unload. I suspect but didn't test that python gc performance will be slightly faster. Changes required to implement and test: 3. Use python's platform package to determine what we're running on, so we can use the right mmap/mprotect or VirtualAlloc/VirtualProtect routines, the right flags for mmap, and (theoretically) the right native code. Side effect: to port to a new platform requires updating some additional code now. 4. New unit tests. (a) A new test for domain reload. It doesn't run under .NET Core because you can't create and unload a domain in .NET Core. (b) New unit tests to help us find where to add support for new platforms.
Minimal Py_IntializeEx change
Convertes System.Decimal to decimal.decimal and vice-versa
Converts System.DateTime and System.TimeSpan to datetime.datetime and datetime.timedelta and vice-versa
DECREF'ing datetime timezone argument when DateTimeKind is Unspecified was causing `Fatal Python error: deallocating None` because the object was set to `Runtime.PyNone`. Fixed the input to datetime constructor as we were passing milliseconds, where it should be microseconds.
- C# decimal conversion will use C# double and python float due to the big performance impact of converting C# decimal to python decimal.
| Exceptions.Clear(); | ||
| // Make sure we clean up properly on app domain unload. | ||
| AppDomain.CurrentDomain.DomainUnload += OnDomainUnload; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the application and pythonnet running in the same app domain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. AppDomain.CurrentDomain is QuantConnect.Lean.Launcher.exe when I run Lean.
No description provided.