Skip to content

Commit 431b4dd

Browse files
committed
Debug in CI
1 parent e81d7a7 commit 431b4dd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/unit/_utils/test_system.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
from __future__ import annotations
22

33
import gc
4+
import os
45
import time
56
from multiprocessing import Array, Process, Value
67
from typing import TYPE_CHECKING
78

9+
import psutil
10+
811
from crawlee._utils.byte_size import ByteSize
912
from crawlee._utils.system import get_cpu_info, get_memory_info
1013

@@ -58,7 +61,10 @@ def _parent_function(ratio: Synchronized) -> None:
5861
for child in nonsharing_children:
5962
child.join()
6063

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")
6268

6369

6470
def test_memory_measurement_of_shared_memory() -> None:
@@ -74,10 +80,11 @@ def test_memory_measurement_of_shared_memory() -> None:
7480
# The threshold for memory usage ratio of unshared_used_memory processes and shared_used_memory processes
7581
good_enough_threshold = 0.5
7682

77-
shared_vs_nonshared_used_memory_ratio: Synchronized = Value('d', 0.0)
83+
shared_vs_nonshared_used_memory_ratio: Synchronized = Value('c', b' '*10000)
7884

7985
process = Process(target=_parent_function, args=(shared_vs_nonshared_used_memory_ratio,))
8086
process.start()
8187
process.join()
8288

89+
raise Exception(shared_vs_nonshared_used_memory_ratio.value.decode("utf-8"))
8390
assert shared_vs_nonshared_used_memory_ratio.value < good_enough_threshold

0 commit comments

Comments
 (0)