うーん

できの悪い udp echo server ... pyevent 使用。
thread がぁー。

import socket
import traceback
import event
import time
import thread

host = ''
port = 12345

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind((host, port))

def time_thread(sock, message, address):
  sock.sendto(message, address)
  time.sleep(5)
  print "Got data from", address

def handle_read(ev, sock, entype, args):
  try:
    message, address = sock.recvfrom(4096)
    thread.start_new_thread(time_thread, (sock, message, address))
  except (KeyboardInterrupt, SystemExit):
    raise
  except:
    traceback.print_exc()

if __name__ == '__main__':
  event.init()
  event.event(handle_read, handle=sock, evtype=event.EV_READ | event.EV_PERSIST).add()
  event.dispatch()