Skip to content

Commit a041811

Browse files
authored
Ensure that load only runs once (#2079)
Fixes #2078.
1 parent 4020a0c commit a041811

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

+2-1
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

+5-1
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)