@@ -387,23 +387,29 @@ test_version(_Config) ->
387387 ok .
388388
389389test_memory_stats (_Config ) ->
390- {ok , Stats } = py :memory_stats (),
391- true = is_map (Stats ),
392- % % Check that we have GC stats
393- true = maps :is_key (gc_stats , Stats ),
394- true = maps :is_key (gc_count , Stats ),
395- true = maps :is_key (gc_threshold , Stats ),
396-
397- % % Test tracemalloc
398- ok = py :tracemalloc_start (),
399- % % Allocate some memory
400- {ok , _ } = py :eval (<<" [x**2 for x in range(1000)]" >>),
401- {ok , StatsWithTrace } = py :memory_stats (),
402- true = maps :is_key (traced_memory_current , StatsWithTrace ),
403- true = maps :is_key (traced_memory_peak , StatsWithTrace ),
404- ok = py :tracemalloc_stop (),
390+ % % tracemalloc doesn't support subinterpreters
391+ case py_nif :subinterp_supported () of
392+ true ->
393+ {skip , " tracemalloc not supported in subinterpreters" };
394+ false ->
395+ {ok , Stats } = py :memory_stats (),
396+ true = is_map (Stats ),
397+ % % Check that we have GC stats
398+ true = maps :is_key (gc_stats , Stats ),
399+ true = maps :is_key (gc_count , Stats ),
400+ true = maps :is_key (gc_threshold , Stats ),
401+
402+ % % Test tracemalloc
403+ ok = py :tracemalloc_start (),
404+ % % Allocate some memory
405+ {ok , _ } = py :eval (<<" [x**2 for x in range(1000)]" >>),
406+ {ok , StatsWithTrace } = py :memory_stats (),
407+ true = maps :is_key (traced_memory_current , StatsWithTrace ),
408+ true = maps :is_key (traced_memory_peak , StatsWithTrace ),
409+ ok = py :tracemalloc_stop (),
405410
406- ok .
411+ ok
412+ end .
407413
408414test_gc (_Config ) ->
409415 % % Test basic GC
@@ -912,25 +918,31 @@ assert val == 2, f'Expected 2, got {val}'
912918
913919% % Test module reload across all workers
914920test_reload (_Config ) ->
915- % % First, ensure json module is imported in at least one worker
916- {ok , _ } = py :call (json , dumps , [[1 , 2 , 3 ]]),
921+ % % Module reload can trigger imports that don't support subinterpreters
922+ case py_nif :subinterp_supported () of
923+ true ->
924+ {skip , " module reload may use modules not supported in subinterpreters" };
925+ false ->
926+ % % First, ensure json module is imported in at least one worker
927+ {ok , _ } = py :call (json , dumps , [[1 , 2 , 3 ]]),
917928
918- % % Now reload it - should succeed across all workers
919- ok = py :reload (json ),
929+ % % Now reload it - should succeed across all workers
930+ ok = py :reload (json ),
920931
921- % % Verify the module still works after reload
922- {ok , <<" [1, 2, 3]" >>} = py :call (json , dumps , [[1 , 2 , 3 ]]),
932+ % % Verify the module still works after reload
933+ {ok , <<" [1, 2, 3]" >>} = py :call (json , dumps , [[1 , 2 , 3 ]]),
923934
924- % % Test reload of a module that might not be loaded (should not error)
925- ok = py :reload (collections ),
935+ % % Test reload of a module that might not be loaded (should not error)
936+ ok = py :reload (collections ),
926937
927- % % Test reload with binary module name
928- ok = py :reload (<<" os" >>),
938+ % % Test reload with binary module name
939+ ok = py :reload (<<" os" >>),
929940
930- % % Test reload with string module name
931- ok = py :reload (" sys" ),
941+ % % Test reload with string module name
942+ ok = py :reload (" sys" ),
932943
933- ok .
944+ ok
945+ end .
934946
935947% %% ============================================================================
936948% %% ASGI Optimization Tests
0 commit comments