forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
jaredbroad
reviewed
Jan 15, 2019
initialized = true; | ||
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.
jaredbroad
approved these changes
Jan 15, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.