Skip to content

Commit c79d22f

Browse files
committed
Ensure that load only runs once
Fixes #2078.
1 parent 4020a0c commit c79d22f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
1313

1414
### Fixed
1515

16-
- Fixed error occuring when inheriting a class containing a virtual generic method.
16+
- Fixed error occuring when inheriting a class containing a virtual generic method.
17+
- Make a second call to `pythonnet.load` a no-op, as it was intended.
1718

1819
## [3.0.1](https://github.com/pythonnet/pythonnet/releases/tag/v3.0.1) - 2022-11-03
1920

pythonnet/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ def load(runtime: Union[clr_loader.Runtime, str, None] = None, **params: str) ->
120120
121121
The same parameters as for `set_runtime` can be used. By default,
122122
`set_default_runtime` is called if no environment has been set yet and no
123-
parameters are passed."""
123+
parameters are passed.
124+
125+
After a successful call, further invocations will return immediately."""
124126
global _LOADED, _LOADER_ASSEMBLY
125127

126128
if _LOADED:
@@ -142,6 +144,8 @@ def load(runtime: Union[clr_loader.Runtime, str, None] = None, **params: str) ->
142144

143145
if func(b"") != 0:
144146
raise RuntimeError("Failed to initialize Python.Runtime.dll")
147+
148+
_LOADED = True
145149

146150
import atexit
147151

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy