File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
3
import gc
4
+ import os
4
5
import time
5
6
from multiprocessing import Array , Process , Value
6
7
from typing import TYPE_CHECKING
7
8
9
+ import psutil
10
+
8
11
from crawlee ._utils .byte_size import ByteSize
9
12
from crawlee ._utils .system import get_cpu_info , get_memory_info
10
13
@@ -58,7 +61,10 @@ def _parent_function(ratio: Synchronized) -> None:
58
61
for child in nonsharing_children :
59
62
child .join ()
60
63
61
- ratio .value = memory_when_sharing_children .current_size / memory_when_nonsharing_children .current_size
64
+ # DEBUG in CI
65
+ current_process = psutil .Process (os .getpid ())
66
+
67
+ ratio .value = repr (current_process .memory_full_info ()).encode ("utf-8" )
62
68
63
69
64
70
def test_memory_measurement_of_shared_memory () -> None :
@@ -74,10 +80,11 @@ def test_memory_measurement_of_shared_memory() -> None:
74
80
# The threshold for memory usage ratio of unshared_used_memory processes and shared_used_memory processes
75
81
good_enough_threshold = 0.5
76
82
77
- shared_vs_nonshared_used_memory_ratio : Synchronized = Value ('d ' , 0.0 )
83
+ shared_vs_nonshared_used_memory_ratio : Synchronized = Value ('c ' , b' ' * 10000 )
78
84
79
85
process = Process (target = _parent_function , args = (shared_vs_nonshared_used_memory_ratio ,))
80
86
process .start ()
81
87
process .join ()
82
88
89
+ raise Exception (shared_vs_nonshared_used_memory_ratio .value .decode ("utf-8" ))
83
90
assert shared_vs_nonshared_used_memory_ratio .value < good_enough_threshold
You can’t perform that action at this time.
0 commit comments