Title: Cannot run twice; Unity crashes after running more than once · Issue #701 · pythonnet/pythonnet · GitHub
Open Graph Title: Cannot run twice; Unity crashes after running more than once · Issue #701 · pythonnet/pythonnet
X Title: Cannot run twice; Unity crashes after running more than once · Issue #701 · pythonnet/pythonnet
Description: Environment Pythonnet version: 2.3.0 py35 Python version: 3.5.4 Operating System: Windows 10 Details I want to run this code on my Unity project: using Python.Runtime; using UnityEngine; public class TestLib : MonoBehaviour { // Use this...
Open Graph Description: Environment Pythonnet version: 2.3.0 py35 Python version: 3.5.4 Operating System: Windows 10 Details I want to run this code on my Unity project: using Python.Runtime; using UnityEngine; public cla...
X Description: Environment Pythonnet version: 2.3.0 py35 Python version: 3.5.4 Operating System: Windows 10 Details I want to run this code on my Unity project: using Python.Runtime; using UnityEngine; public cla...
Opengraph URL: https://github.com/pythonnet/pythonnet/issues/701
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot run twice; Unity crashes after running more than once","articleBody":"### Environment\r\n\r\n- Pythonnet version: 2.3.0 py35\r\n- Python version: 3.5.4\r\n- Operating System: Windows 10\r\n\r\n### Details\r\n\r\nI want to run this code on my Unity project:\r\n```cs\r\nusing Python.Runtime;\r\nusing UnityEngine;\r\n\r\npublic class TestLib : MonoBehaviour\r\n{\r\n // Use this for initialization\r\n private void Start()\r\n {\r\n print(\"initializing python\");\r\n PythonEngine.Initialize();\r\n print(\"running python code\");\r\n using (Py.GIL())\r\n {\r\n dynamic np = Py.Import(\"numpy\");\r\n print(np.cos(np.pi * 2));\r\n }\r\n\r\n print(\"Destroying python engine\");\r\n PythonEngine.Shutdown();\r\n }\r\n}\r\n```\r\nHere's the output:\r\n\r\n\r\n\r\nIt's able to run once but when I try to run it again, Unity editor crashes.\r\n\r\nHere's the entire process:\r\nI open Unity. Inside it, I click *play* to run this code, it works. And then I stop, and then I run the code again, Unity crashes.\r\n\r\n#### Reasoning\r\n- I'm suspecting that it's because python is still running in the background when I stop the game session.\r\nBut I tried Initialize() and Shutdown() twice in the code and it works (if I run it once). So I think it's not shutting down issue. It's something else that I cannot figure out.\r\n- This error depends on the python code for sure. If I remove the python part and run, it would be able to run as many times as I want.\r\n- It might also be a threading issue which I don't understand.\r\n\r\n\r\nWhat are the possible causes and fixes?\r\n","author":{"url":"https://github.com/offchan42","@type":"Person","name":"offchan42"},"datePublished":"2018-07-05T22:01:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/701/pythonnet/issues/701"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:729c8816-48f9-9de0-c728-c446ac67bd0b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B6DC:36ED6F:273573:347426:69715563 |
| html-safe-nonce | 23fdfef161383b3cccf28b7e78c651f44adf69dc932224c3b2b6a454263f979d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkRDOjM2RUQ2RjoyNzM1NzM6MzQ3NDI2OjY5NzE1NTYzIiwidmlzaXRvcl9pZCI6Ijg0NzE4NjcyNTcwNjE5ODc2ODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 94d04c4a24795eb1630a99967a6fea1f0a9a0cf3806c5a78d21b75029a15cd6e |
| hovercard-subject-tag | issue:338740096 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pythonnet/pythonnet/701/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6c8b1fdd32d3d9642dbf50fe2823efb1b896526af70e8e15a010794ccce7eb54/pythonnet/pythonnet/issues/701 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6c8b1fdd32d3d9642dbf50fe2823efb1b896526af70e8e15a010794ccce7eb54/pythonnet/pythonnet/issues/701 |
| og:image:alt | Environment Pythonnet version: 2.3.0 py35 Python version: 3.5.4 Operating System: Windows 10 Details I want to run this code on my Unity project: using Python.Runtime; using UnityEngine; public cla... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | offchan42 |
| hostname | github.com |
| expected-hostname | github.com |
| None | fd5876ec68f4a61d42f4010f6d1b2764d8ae314777de44028a7708a1d7bac1b5 |
| turbo-cache-control | no-preview |
| go-import | github.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git |
| octolytics-dimension-user_id | 6050430 |
| octolytics-dimension-user_login | pythonnet |
| octolytics-dimension-repository_id | 14748123 |
| octolytics-dimension-repository_nwo | pythonnet/pythonnet |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14748123 |
| octolytics-dimension-repository_network_root_nwo | pythonnet/pythonnet |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8f48ed2345879fb640360c3a24f1d1780c3ed3cb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width