Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2011
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. def run(daemonize=False, db=None):
  2.     from gevent import server
  3.     if daemonize:
  4.         pid = gevent.fork()
  5.         if pid != 0:
  6.             return pid
  7.         else:
  8.             gevent.reinit()
  9.     db = db or settings.POSTGRESQL
  10.     database.pool(*settings.POSTGRESQL_POOL,    
  11.                           custom_settings=db)
  12.     worker = Worker()
  13.     srv = server.StreamServer(("0.0.0.0", settings.LISTEN_PORT),
  14.                                worker.handle_connection)
  15.     try:
  16.         srv.serve_forever()
  17.     except KeyboardInterrupt:
  18.         pass
  19.  
  20. if __name__ == "__main__":
  21.     run()
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement