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 1
1
import asyncio
2
2
from unittest .mock import MagicMock
3
3
4
+ import psutil
4
5
import pytest
5
6
import tornado
6
7
7
- from nbclient .util import run_hook , run_sync
8
+ from nbclient .util import just_run , run_hook , run_sync
8
9
9
10
10
11
@run_sync
@@ -75,3 +76,21 @@ async def test_run_hook_async():
75
76
hook = MagicMock (return_value = some_async_function ())
76
77
await run_hook (hook )
77
78
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
7
7
mypy
8
8
pip >= 18.1
9
9
pre-commit
10
+ psutil
10
11
pytest >= 4.1
11
12
pytest-asyncio
12
13
pytest-cov >= 2.6.1
You can’t perform that action at this time.
0 commit comments