nodejs运行python_如何在后台Python中运行子进程命令来启动nodejs服务器
匿名用户
使用内置的asyncio库和asyncio.Gather,可以并发运行函数。下面是一个概念验证/演示,您可以将代码填入其中:import asyncio
#import subprocess
async def runNodeScript():
print('Running script...')
await asyncio.sleep(1) #simulate lengthy tasks
print('Done with script')
#You'd place the subprocess call here (though obviously first removing the demo code above):
#subprocess.check_output(["node", "path/to/script"])
async def runOtherCode():
print('Running other code...') #place the code below the subprocess call here
async def main():
await asyncio.gather( #run functions concurrently
runNodeScript(),
runOtherCode()
)
asyncio.run(main())
print('Done with everything')
输出:Running script...
Running other code...
Done with script
Done with everything
[Program finished]
这是我做的一个repl,这样你就可以在线测试和编辑代码了。
nodejs运行python_如何在后台Python中运行子进程命令来启动nodejs服务器相关推荐
- cmd无法运行python_通过Java-%1在cmd中运行python文件不是有效的Win32应用程序 - java...
我正在尝试使用Java执行python代码.我的代码: public class PyTest { public static void main(String[] args) { Runtime.g ...
- Python中执行外部命令
有很多需求需要在Python中执行shell命令.启动子进程,并捕获命令的输出和退出状态码,类似于Java中的Runtime类库. subprocess模块的使用: Python使用最广泛的是标准库的 ...
- python运行命令_对python中执行DOS命令的3种方法总结
1. 使用os.system("cmd") 特点是执行的时候程序会打出cmd在Linux上执行的信息. import os os.system("ls") 2. ...
- python运行外部程序_在Python中运行外部程序(可执行文件)?
在Python中运行外部程序(可执行文件)? 我刚刚开始研究Python,我一直在尝试从Python运行外部可执行文件. 我有一个用Fortran编写的程序的可执行文件. 假设可执行文件的名称是flo ...
- python运行方法_对python中执行DOS命令的3种方法总结
1. 使用os.system("cmd") 特点是执行的时候程序会打出cmd在Linux上执行的信息. import os os.system("ls") 2. ...
- linux中python进程,如何检查进程在python中运行(在linux中)?
我想如果这个过程是基于进程名(test.py)上运行的检查,然后退出如何检查进程在python中运行(在linux中)? l = commands.getstatusoutput("ps a ...
- 在Python中运行Excel的VBA宏
转载自https://www.cnblogs.com/russellluo/archive/2011/10/16/2214347.html 并加以细化 在EXCEL的VBA中提供了一个ExecuteE ...
- python调用shell命令-在Python中执行shell命令的6种方法,你都知道吗?
原标题:在Python中执行shell命令的6种方法,你都知道吗? Python经常被称作"胶水语言",因为它能够轻易地操作其他程序,轻易地包装使用其他语言编写的库.今天我们就讲解 ...
- python使用教程cmd啥意思-对python中执行DOS命令的3种方法总结
1. 使用os.system("cmd") 特点是执行的时候程序会打出cmd在Linux上执行的信息. import os os.system("ls") 2. ...
最新文章
- 使用pymongo将文件存入MongoDB
- 系统消息是放客户端还是服务器,系统消息是放客户端还是服务器
- React总结篇之十_动画
- 【专访】PP租车创业故事二:为什么要创业?
- H5_ 多媒体video,autio使用示例
- JMeter处理Cookie与Session
- 怎样王远端服务器上传文件,传王电子传真使用指南-Freefax传真服务器,传王A6,免费传真...
- 服务器使用nginx做代理,通过HttpServletRequest获取请求用户真实IP地址
- php 受保护的方法调用_PHP_PHP中对用户身份认证实现两种方法,当访问者浏览受保护页面时, - phpStudy...
- java面试 线程_Java面试题(线程)
- pointnet源码阅读:训练
- FastAPI 快速入门
- 浅析物联网行业市场最新发展趋势
- Python创建文件夹和子文件夹
- uniapp自定义导航栏的开发
- 丰县中等专业学校计算机专业,江苏省丰县中等专业学校2020
- Altium Designer 21 原理图库元件模型的组成介绍以及简单的电阻电容元件模型的创建
- 晶体三极管及其基本放大电路
- linux下su的demos编译,SU Demos-02Filtering-05Suk1k2filter
- easyUI之增加删除与批量删除