I am currently working on asyncio with python 3.7.x not sure about the exact version, right now I am trying to schedule a task. And I am unable to get an output, even when running the thing forever. Here is the code I currently have
import asyncio
async def print_now():
print("Hi there")
loop = asyncio.get_event_loop()
loop.call_later(print_now())
loop.run_until_complete(asyncio.sleep(1))
This gives the following error:
Traceback (most recent call last):
File "D:\Coding\python\async\main.py", line 7, in <module>
loop.call_later(print_now())
TypeError: call_later() missing 1 required positional argument: 'callback'
The call back in call_later()
is print_now
I've tried just print_now
and print_now()
I have also tried using loop.run_forever()
instead of loop.run_until_complete()
and so far I didn't get anything
Sometimes I get either no output or a different error.