more Markdown stuff
[synarere.git] / core / io.py
blob0b6e81291363198f8dd2c8d81ee81cd47f637e83
1 # synarere -- a highly modular and stable IRC bot.
2 # Copyright (C) 2010 Michael Rodriguez.
3 # Rights to this code are documented in docs/LICENSE.
5 '''Main loop.'''
7 # Import required Python modules.
8 import asyncore, time
10 # Import required core modules.
11 import timer, var
13 def io():
14 '''Infinite loop to handle routines.'''
16 while True:
17 # Check for timers.
18 delay = timer.next_run()
20 if delay <= time.time():
21 timer.run()
23 # We don't want to poll on no connections because it makes CPU usage skyrocket.
24 # Instead, just sleep.
25 if len(var.conns) == 0:
26 time.sleep(1)
27 else:
28 asyncore.poll(1)