Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak and high CPU after stepping over mocker.patch("time.sleep") from pytest-mock #1766

Closed
freetomik opened this issue Sep 19, 2024 · 1 comment
Assignees
Labels
needs repro Issue has not been reproduced yet

Comments

@freetomik
Copy link

Type: Performance Issue

  1. with following Python code and installed packages pytest and pytest-mock:
import time

def test_sleep_with_mock(mocker):
    mocker.patch("time.sleep")
    time.sleep(5)
    time.sleep.assert_called_once_with(5)
  1. set breakpoint on line with mocker.patch(...)
  2. start test debugging (via Testing icon on Activity Bar)
  3. step over the line (F10)
  • expected behaviour:
    CPU and memory stay and same level like before stepping over the line. On Continue (F5) test finishes.

  • actual behaviour:
    CPU goes from 5% to 25% and memory starts to gradually increase. On Continue (F5) test hangs.

Windows 10 Pro 22H2 19045.4046, x64
Python 3.12.6
pytest==8.1.2
pytest-mock==3.14.0

VS Code version: Code 1.93.1 (38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40, 2024-09-11T17:20:05.685Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz (8 x 2803)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 15.69GB (4.14GB free)
Process Argv --crash-reporter-id dfe8ae6d-b221-4f14-9a09-388238534166
Screen Reader no
VM 0%
Process Info
CPU %	Mem MB	   PID	Process
    0	   120	 43112	code main
    0	   182	  9060	   gpu-process
    0	    43	 25048	   utility-network-service
    0	    27	 26756	   crashpad-handler
    0	   273	 27592	window [1] (test_sleep2.py - pytest-mock-example - Visual Studio Code)
    0	   109	 38540	shared-process
    0	    88	 42892	fileWatcher [1]
    0	   432	 44828	extensionHost [1]
    0	   361	  4680	     electron-nodejs (bundle.js )
    0	     7	 37708	     c:\Users\<user>\.vscode\extensions\ms-python.python-2024.14.1-win32-x64\python-env-tools\bin\pet.exe server
    0	    11	 13304	       C:\windows\system32\conhost.exe 0x4
    0	     4	 41544	     "c:\Users\<user>\Documents\Python skripty\pytest-mock-example\.venv\Scripts\python.exe" c:\Users\<user>\.vscode\extensions\ms-python.isort-2023.10.1\bundled\tool\lsp_server.py
    0	    48	 38556	       "C:\Users\<user>\AppData\Local\Programs\Python\Python312\python.exe" c:\Users\<user>\.vscode\extensions\ms-python.isort-2023.10.1\bundled\tool\lsp_server.py
    0	    11	 41000	       C:\windows\system32\conhost.exe 0x4
    0	   113	 45968	ptyHost
    0	   100	  3856	     "C:\Program Files\PowerShell\7\pwsh.exe" -noexit -command "try { . \"c:\Users\<user>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1\" } catch {}"
    0	     6	  6500	     conpty-agent
    0	     6	 15724	     conpty-agent
    0	   108	 22500	     "C:\Program Files\PowerShell\7\pwsh.exe" -noexit -command "try { . \"c:\Users\<user>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1\" } catch {}"
    0	   100	 22820	     "C:\Program Files\PowerShell\7\pwsh.exe" -noexit -command "try { . \"c:\Users\<user>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1\" } catch {}"
    0	    96	 30528	     "C:\Program Files\PowerShell\7\pwsh.exe" -noexit -command "try { . \"c:\Users\<user>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1\" } catch {}"
    0	    99	 36596	     "C:\Program Files\PowerShell\7\pwsh.exe" -noexit -command "try { . \"c:\Users\<user>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1\" } catch {}"
    0	     6	 42568	     conpty-agent
    0	     7	 42752	     conpty-agent
    0	     6	 45608	     conpty-agent
Workspace Info
|  Window (test_sleep2.py - pytest-mock-example - Visual Studio Code)
|    Folder (pytest-mock-example): 8310 files
|      File types: pyc(2233) py(2231) gz(1052) json(870) txt(40) pyi(36)
|                  typed(27) exe(16) pyd(6) md(5)
|      Conf files: settings.json(1);
Extensions (26)
Extension Author (truncated) Version
cucumberautocomplete ale 3.0.5
vscode-log-viewer ber 0.14.1
json-tools eri 1.0.2
prettier-vscode esb 11.0.0
copilot Git 1.231.1112
copilot-chat Git 0.20.2
rainbow-csv mec 3.12.0
playwright ms- 1.1.7
debugpy ms- 2024.10.0
isort ms- 2023.10.1
python ms- 2024.14.1
vscode-pylance ms- 2024.9.1
jupyter ms- 2024.8.1
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.0.19
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
powershell ms- 2024.2.2
vscode-speech ms- 0.10.0
vsliveshare ms- 1.0.5940
playwright-test-snippets msk 1.2.1
LiveServer rit 5.7.9
markdown-preview-enhanced shd 0.8.14
german-scroll Tur 0.2.3
vim vsc 1.28.1
JavaScriptSnippets xab 1.8.0
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
vscrp:30673768
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
jg8ic977:31013176
a69g1124:31058053
dvdeprecation:31068756
dwnewjupytercf:31046870
impr_priority:31102340
nativerepl1:31139838
refactort:31108082
pythonrstrctxt:31112756
flighttreat:31134774
wkspc-onlycs-t:31132770
wkspc-ranged-t:31125599
cf971741:31134768
pme_test_c:31118331
fje88620:31121564
iacca1:31138162

@karthiknadig karthiknadig transferred this issue from microsoft/vscode Dec 11, 2024
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Dec 11, 2024
@rchiodo
Copy link
Contributor

rchiodo commented Dec 11, 2024

I see no such spike in CPU or memory usage. This might have been an issue with the 3.12 debugger that was fixed in the October timeframe.

@rchiodo rchiodo closed this as completed Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet
Projects
None yet
Development

No branches or pull requests

4 participants