File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 11import asyncio
22from unittest .mock import MagicMock
33
4+ import psutil
45import pytest
56import tornado
67
7- from nbclient .util import run_hook , run_sync
8+ from nbclient .util import just_run , run_hook , run_sync
89
910
1011@run_sync
@@ -75,3 +76,21 @@ async def test_run_hook_async():
7576 hook = MagicMock (return_value = some_async_function ())
7677 await run_hook (hook )
7778 assert hook .call_count == 1
79+
80+
81+ def test_just_run_doesnt_leak_fds ():
82+ proc = psutil .Process ()
83+
84+ async def async_sleep ():
85+ await asyncio .sleep (0.01 )
86+
87+ # Warmup, just to make sure we're not failing on some initial fds being opened for the first time.
88+ for _ in range (10 ):
89+ just_run (async_sleep ())
90+ fds_count = proc .num_fds ()
91+
92+ diff = []
93+ for _ in range (10 ):
94+ just_run (async_sleep ())
95+ diff .append (proc .num_fds () - fds_count )
96+ assert diff == [0 ] * 10
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ ipywidgets<8.0.0
77mypy
88pip >= 18.1
99pre-commit
10+ psutil
1011pytest >= 4.1
1112pytest-asyncio
1213pytest-cov >= 2.6.1
You can’t perform that action at this time.
0 commit comments