@@ -554,6 +554,10 @@ public static final class SharedMultiprocessingData {
554
554
*/
555
555
private final Map <Integer , Integer > fdRefCount = new HashMap <>();
556
556
557
+ public SharedMultiprocessingData (ConcurrentHashMap <String , Semaphore > namedSemaphores ) {
558
+ this .namedSemaphores = namedSemaphores ;
559
+ }
560
+
557
561
/**
558
562
* Increases reference count for the given file descriptor.
559
563
*/
@@ -676,11 +680,9 @@ private boolean isClosed(int fd) {
676
680
}
677
681
678
682
/**
679
- * Named semaphores are shared between all processes in a system, and they persist until the
680
- * system is shut down, unless explicitly removed. We interpret this as meaning they all
681
- * exist globally per the main context and all its children.
683
+ * @see PythonLanguage#namedSemaphores
682
684
*/
683
- private final ConcurrentHashMap <String , Semaphore > namedSemaphores = new ConcurrentHashMap <>() ;
685
+ private final ConcurrentHashMap <String , Semaphore > namedSemaphores ;
684
686
685
687
@ TruffleBoundary
686
688
public void putNamedSemaphore (String name , Semaphore sem ) {
@@ -732,7 +734,7 @@ public PythonContext(PythonLanguage language, TruffleLanguage.Env env, Python3Co
732
734
this .core = core ;
733
735
this .env = env ;
734
736
this .childContextData = (ChildContextData ) env .getConfig ().get (CHILD_CONTEXT_DATA );
735
- this .sharedMultiprocessingData = this .childContextData == null ? new SharedMultiprocessingData () : childContextData .parentCtx .sharedMultiprocessingData ;
737
+ this .sharedMultiprocessingData = this .childContextData == null ? new SharedMultiprocessingData (language . namedSemaphores ) : childContextData .parentCtx .sharedMultiprocessingData ;
736
738
this .handler = new AsyncHandler (this );
737
739
this .sharedFinalizer = new AsyncHandler .SharedFinalizer (this );
738
740
this .optionValues = PythonOptions .createOptionValuesStorage (env );
0 commit comments