我正在使用eel创建一个桌面应用程序。但是,我同时运行函数时遇到了一个问题。在
eel的想法是允许electron通过JS与Python通信。因此,我在eelui中创建了一个按钮,它运行我程序的一部分(多个异步aiohttp会话)。运行这些函数的函数被定义为异步的,即async def main():。并且main()运行的所有函数也是异步的。以下是该计划的概要:import eel
import asyncio
from aiohttp import ClientSession
options = {
'mode': 'custom',
'args': ['node_modules/electron/dist/electron.exe', '.'],
}
@eel.expose
async def start_program(): # this is run when the user clicks the run button
await main()
@eel.expose
async def test_print(): # this is run when the user clicks the test button
print("test")
async def main():
tasks = []
loop = asyncio.get_event_loop()
for i in range(instances):
task = asyncio.ensure_future(launch(url))
tasks.append(