René's URL Explorer Experiment


Title: What should reload reload? · Issue #1268 · pythonnet/pythonnet · GitHub

Open Graph Title: What should reload reload? · Issue #1268 · pythonnet/pythonnet

X Title: What should reload reload? · Issue #1268 · pythonnet/pythonnet

Description: Background: Amos created the soft reload branch which is now merged to master. It's a large amount of work. We found #1250 as an issue in that code. Now the question is: disable some functionality or fix it? The setting is as follows: I ...

Open Graph Description: Background: Amos created the soft reload branch which is now merged to master. It's a large amount of work. We found #1250 as an issue in that code. Now the question is: disable some functionality ...

X Description: Background: Amos created the soft reload branch which is now merged to master. It's a large amount of work. We found #1250 as an issue in that code. Now the question is: disable some functional...

Opengraph URL: https://github.com/pythonnet/pythonnet/issues/1268

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"What should reload reload?","articleBody":"**Background:**\r\nAmos created the soft reload branch which is now merged to master. It's a large amount of work.\r\n\r\nWe found #1250 as an issue in that code. Now the question is: disable some functionality or fix it?\r\n\r\nThe setting is as follows: I have code in Python. It stores references to objects in C#. That means there are proxies in Python pointing to objects in C#.\r\n\r\nWhen C# unloads the domain, those proxies are now pointing to garbage. In the setting where this happens (Unity domain reload), C# will soon load a new domain. The new domain will be a lot like the old one.\r\n\r\nAmos implemented a mechanism in `runtime_data.cs` to reconnect the proxies. The idea is we know all the proxies that were ever build (and not yet deleted). Serialize that C# data using `System.Runtime.Serialization`. When the new domain arrives, deserialize.\r\n\r\n**Problem:**\r\nDeserialization may fail. See #1250 for one example.\r\n\r\nThis happens in practice when the Unity user renames a field, a class, a namespace, or an assembly -- and on the Python side we had a reference to one of those. E.g. if we handed a C# static function to a python function that expects a callable, we'd have a FieldObject proxy in the code. If the user renames or deletes the C# static function in their code, when Unity reloads the domain, that FieldObject won't be able to reload.\r\n\r\nThis will cause an exception when trying to reinitialize Python for .NET on the C# side, and therefore the system is now in an undefined state.\r\n\r\nThe `System.Runtime.Serialization` is not fault tolerant. It's not possible to provide a callback if deserialization fails for a certain object. If you control a class you can specify custom deserialization (and serialization) for that class, and you can specifically code your stuff to be fault tolerant, but if you recursively serialize any other classes, upon deserialization everything that got serialized gets deserialized as a flat list; any unhandled exceptions there will stop the deserialization.\r\n\r\n**What are the user requirements anyway?**\r\n\r\nFor a Unity user, the requirement is that when I change my C# code and Unity automatically reloads, the Python side doesn't throw a fit no matter how mean I've been to it.\r\n\r\nThis is mainly two things:\r\n1. If in Python I `import MyModule` where MyModule is in C# (this includes `UnityEngine`), I need some way to be able to use that even after a domain reload. Ideally the module reloads itself.\r\n2. If in Python I somehow store a reference to a proxy to C#, I need that the system is able to survive domain reload: it does not crash and it does not leave the Python for .NET data structures in an unstable state.\r\n\r\n**Possible solution 1: fix the bugs**\r\nIn #1250 I prototyped a possible solution. The reason deserialization fails in that case is that FieldObject (in `runtime/fieldobject.cs`) stores a System.Reflection.FieldInfo. Since it can't find that field after reloading, deserialization throws an exception.\r\n\r\nSolution: \r\n1. Add custom serialization to FieldObject.\r\n2. Serialize the FieldInfo into its own serialization context and store the byte stream.\r\n3. When we deserialize the FieldObject, deserialize the FieldInfo from that byte stream.\r\n4. If that fails, catch the exception and mark the FieldObject invalid. When someone wants to access the FieldInfo in the FieldObject, throw an exception.\r\n\r\nEffectively this delays the exception so that we can deserialize everything that works and we delay exceptions until the point of use.\r\n\r\nThere are 13 subclasses of ManagedType that store a pointer to some other object. We can write custom serializations for all of them.\r\n\r\nThere probably are some ManagedType subclasses that can't reasonably be reloaded, e.g. CLRObject. Those need to simply not serialize, and then fail gracefully just like the others.\r\n\r\n**Possible solution 2: disable reconnecting the proxies**\r\nAn alternate plan that Mohammed brought up: what if we just don't reload at all.\r\n\r\nWe'd basically just add a `DisableProxy()` function to ManagedType. Most functions on every ManagedType would need to check if the ManagedType is disabled, and if so raise an exception on use. Probably keep ToString working, definitely keep the finalizer/Dispose working.\r\n\r\n**Possible solution 3: hybrid**\r\nFigure out the most important things to reload, and reload those. Probably this is modules (namespaces) and assemblies.\r\n\r\nFor everything else, disable the proxy.","author":{"url":"https://github.com/benoithudson","@type":"Person","name":"benoithudson"},"datePublished":"2020-10-22T17:17:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/1268/pythonnet/issues/1268"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:60d78a64-6436-4e03-e71b-c41f34e0e052
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id96C0:FE136:30A5CB5:314C914:69702D94
html-safe-nonceec5a07b727adee398948db8a3c750078dcb5a645eb0168b3f3a134f4f4b134da
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NkMwOkZFMTM2OjMwQTVDQjU6MzE0QzkxNDo2OTcwMkQ5NCIsInZpc2l0b3JfaWQiOiI4ODU0NjM1MDUxNzE5MDc3MjY4IiwicmVnaW9uX2VkZ2UiOiJzZWEiLCJyZWdpb25fcmVuZGVyIjoic2VhIn0=
visitor-hmac470003a319b254e093b1955dc827310248f804704a02540e1196bc0a376bc51b
hovercard-subject-tagissue:727576955
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pythonnet/pythonnet/1268/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c96e2d8a365fcb8d869b46df24eca0b6bdf03e0d5e2ae2756dd554810eba9807/pythonnet/pythonnet/issues/1268
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c96e2d8a365fcb8d869b46df24eca0b6bdf03e0d5e2ae2756dd554810eba9807/pythonnet/pythonnet/issues/1268
og:image:altBackground: Amos created the soft reload branch which is now merged to master. It's a large amount of work. We found #1250 as an issue in that code. Now the question is: disable some functionality ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebenoithudson
hostnamegithub.com
expected-hostnamegithub.com
None9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2
turbo-cache-controlno-preview
go-importgithub.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git
octolytics-dimension-user_id6050430
octolytics-dimension-user_loginpythonnet
octolytics-dimension-repository_id14748123
octolytics-dimension-repository_nwopythonnet/pythonnet
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id14748123
octolytics-dimension-repository_network_root_nwopythonnet/pythonnet
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef643964067a552f02067066d6a910b2f90a5721f
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/pythonnet/pythonnet/issues/1268#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpythonnet%2Fpythonnet%2Fissues%2F1268
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpythonnet%2Fpythonnet%2Fissues%2F1268
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=pythonnet%2Fpythonnet
Reloadhttps://github.com/pythonnet/pythonnet/issues/1268
Reloadhttps://github.com/pythonnet/pythonnet/issues/1268
Reloadhttps://github.com/pythonnet/pythonnet/issues/1268
pythonnet https://github.com/pythonnet
pythonnethttps://github.com/pythonnet/pythonnet
Notifications https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Fork 770 https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Star 5.4k https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Code https://github.com/pythonnet/pythonnet
Issues 155 https://github.com/pythonnet/pythonnet/issues
Pull requests 18 https://github.com/pythonnet/pythonnet/pulls
Discussions https://github.com/pythonnet/pythonnet/discussions
Actions https://github.com/pythonnet/pythonnet/actions
Projects 0 https://github.com/pythonnet/pythonnet/projects
Wiki https://github.com/pythonnet/pythonnet/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/pythonnet/pythonnet/security
Please reload this pagehttps://github.com/pythonnet/pythonnet/issues/1268
Insights https://github.com/pythonnet/pythonnet/pulse
Code https://github.com/pythonnet/pythonnet
Issues https://github.com/pythonnet/pythonnet/issues
Pull requests https://github.com/pythonnet/pythonnet/pulls
Discussions https://github.com/pythonnet/pythonnet/discussions
Actions https://github.com/pythonnet/pythonnet/actions
Projects https://github.com/pythonnet/pythonnet/projects
Wiki https://github.com/pythonnet/pythonnet/wiki
Security https://github.com/pythonnet/pythonnet/security
Insights https://github.com/pythonnet/pythonnet/pulse
New issuehttps://github.com/login?return_to=https://github.com/pythonnet/pythonnet/issues/1268
New issuehttps://github.com/login?return_to=https://github.com/pythonnet/pythonnet/issues/1268
What should reload reload?https://github.com/pythonnet/pythonnet/issues/1268#top
https://github.com/benoithudson
https://github.com/benoithudson
benoithudsonhttps://github.com/benoithudson
on Oct 22, 2020https://github.com/pythonnet/pythonnet/issues/1268#issue-727576955
#1250https://github.com/pythonnet/pythonnet/issues/1250
#1250https://github.com/pythonnet/pythonnet/issues/1250
#1250https://github.com/pythonnet/pythonnet/issues/1250
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.