Created
November 26, 2021 13:21
-
-
Save laixintao/77b751b0a59d87cfbadf387637db561d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
async def subshell(): | |
print("start sleep...") | |
process = await asyncio.create_subprocess_shell( | |
"sleep 23", | |
) | |
print("sub process create, my id {}".format(process, process.pid)) | |
await asyncio.sleep(23) | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(subshell()) |
Linux:
vagrant@vagrant:~$ python3 asy.py
start sleep...
sub process create: <Process 13275>, 13275
vagrant@vagrant:~$ pstree -lasp 13275
systemd,1
└─sshd,2096
└─sshd,13174
└─sshd,13213
└─bash,13214
└─python3,13274 asy.py
└─sh,13275 -c sleep 13
└─sleep,13277 13
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mac: