apscheduler.schedulers.asyncio import AsyncIOScheduler
def tick():
print('Tick! The time is: %s' % datetime.now())
if __name__ == '__main__':
scheduler = AsyncIOScheduler({'apscheduler.timezone': 'UTC'})
scheduler.add_job(tick, 'interval', seconds=3)
scheduler.start()
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
# Execution will block here until Ctrl+C (Ctrl+Break on Windows) is pressed.
try:
asyncio.get_event_loop().run_forever()
except (KeyboardInterrupt, SystemExit):
pass
после запуска выдает:
/Users/mainuser/PycharmProjects/firster/main.py:20: DeprecationWarning: There is no current event loop
asyncio.get_event_loop().run_forever()
https://docs.python.org/3.10/library/asyncio-eventloop.html#asyncio.get_event_loop
Обсуждают сегодня