File: 0003-Use-native-syntax-for-coroutines.patch

package info (click to toggle)
python-memory-profiler 0.61-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 600 kB
  • sloc: python: 2,228; makefile: 33
file content (47 lines) | stat: -rw-r--r-- 1,611 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From: Dmitry Shachnev <mitya57@debian.org>
Date: Sat, 7 Dec 2024 22:45:07 +0300
Subject: Use native syntax for coroutines

Forwarded: no
---
 memory_profiler.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/memory_profiler.py b/memory_profiler.py
index f0b52cd..e03993f 100644
--- a/memory_profiler.py
+++ b/memory_profiler.py
@@ -10,7 +10,6 @@ _CMD_USAGE = "python -m memory_profiler script_file.py"
 from asyncio import iscoroutinefunction
 from contextlib import contextmanager
 from functools import partial, wraps
-from types import coroutine
 import builtins
 import inspect
 import linecache
@@ -750,10 +749,9 @@ class LineProfiler(object):
         """
 
         if iscoroutinefunction(func):
-            @coroutine
-            def f(*args, **kwargs):
+            async def f(*args, **kwargs):
                 with self._count_ctxmgr():
-                    res = yield from func(*args, **kwargs)
+                    res = await func(*args, **kwargs)
                     return res
         else:
             def f(*args, **kwds):
@@ -1175,10 +1173,9 @@ def profile(func=None, stream=None, precision=1, backend='psutil'):
         )
         if iscoroutinefunction(func):
             @wraps(wrapped=func)
-            @coroutine
-            def wrapper(*args, **kwargs):
+            async def wrapper(*args, **kwargs):
                 prof = get_prof()
-                val = yield from prof(func)(*args, **kwargs)
+                val = await prof(func)(*args, **kwargs)
                 show_results_bound(prof)
                 return val
         else: