How can I have more than one loop running ate the same time using the same function but using different parameters like:
@tasks.loop(seconds = 10)
async def loop(name):
Print(name)
loop.start("Jon")
loop.start("Joseph")
Is this how u pass parameters to loops?
You need to create a new Loop
object for each loop. You can do this by using regular function calling repeatedly instead of the decorator:
async def loop(name):
print(name)
names = ["Jon", "Joseph"]
loops = {name: tasks.loop(seconds=10)(name) for name in names}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.