Revision 112d240d lib/http/server.py

b/lib/http/server.py
30 30
import socket
31 31
import time
32 32
import signal
33
import asyncore
33 34

  
34 35
from ganeti import http
35 36

  
......
415 416
    """
416 417
    return self.error_message_format % values
417 418

  
418
class HttpServer(http.HttpBase):
419
class HttpServer(http.HttpBase, asyncore.dispatcher):
419 420
  """Generic HTTP server class
420 421

  
421 422
  Users of this class must subclass it and override the HandleRequest function.
......
445 446

  
446 447
    """
447 448
    http.HttpBase.__init__(self)
449
    asyncore.dispatcher.__init__(self)
448 450

  
449 451
    if request_executor_class is None:
450 452
      self.request_executor = HttpServerRequestExecutor
......
461 463
    self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
462 464

  
463 465
    self._children = []
464

  
465
    mainloop.RegisterIO(self, self.socket.fileno(), select.POLLIN)
466
    self.set_socket(self.socket)
467
    self.accepting = True
466 468
    mainloop.RegisterSignal(self)
467 469

  
468 470
  def Start(self):
......
472 474
  def Stop(self):
473 475
    self.socket.close()
474 476

  
475
  def OnIO(self, fd, condition):
476
    if condition & select.POLLIN:
477
      self._IncomingConnection()
477
  def handle_accept(self):
478
    self._IncomingConnection()
478 479

  
479 480
  def OnSignal(self, signum):
480 481
    if signum == signal.SIGCHLD:

Also available in: Unified diff