Skip to content

Commit 94423cb

Browse files
committed
use io.open instead of open
1 parent c779b3e commit 94423cb

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

memory_profiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import linecache
1616
import logging
1717
import os
18-
from io import open
18+
import io
1919
import pdb
2020
import subprocess
2121
import sys
@@ -1249,7 +1249,7 @@ def exec_with_profiler(filename, profiler, backend, passed_args=[]):
12491249
if _backend == 'tracemalloc' and has_tracemalloc:
12501250
tracemalloc.start()
12511251

1252-
with open(filename, encoding='utf-8') as f:
1252+
with io.open(filename, encoding='utf-8') as f:
12531253
exec(compile(f.read(), filename, 'exec'), ns, ns)
12541254
finally:
12551255
if has_tracemalloc and tracemalloc.is_tracing():

test/test_async.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44

55

66
@profile
7-
@asyncio.coroutine
8-
def my_func():
7+
async def my_func():
98
a = [1] * (10 ** 6)
109
b = [2] * (2 * 10 ** 7)
11-
yield from asyncio.sleep(1e-2)
10+
await asyncio.sleep(1e-2)
1211
del b
13-
return 42
1412

13+
async def main():
14+
task = asyncio.create_task(my_func())
15+
res = await asyncio.gather(task)
1516

1617
if __name__ == '__main__':
17-
loop = asyncio.get_event_loop()
18-
res = loop.run_until_complete(my_func())
19-
assert res == 42
18+
asyncio.run(main()) # main loop

0 commit comments

Comments
 (0)