第17天——————————
因为odoo服务器有三种模式——prefork, gevented, threaded,首先得大致了解一下这三种MPM(Multi-Processing Module,多进程处理模块)模式的特点,可以参考一篇关于apache服务器的博文: http://blog.jobbole.com/91920/
读了这篇博文之后大致了解了这三种模式的区别和优缺点。
接下来看到我们的源代码,由于GeventServer,PreforkServer,ThreadedServer三个类都继承于CommonServer类,其源代码如下:
class CommonServer(object):
def __init__(self, app):
# TODO Change the xmlrpc_* options to http_*
self.app = app #传入的参数是 odoo.service.wsgi_server.application ,先搁置着
# config
self.interface = config['xmlrpc_interface'] or '0.0.0.0' #在我的配置文件中为空
self.port = config['xmlrpc_port’] #在配置文件中可以查看到,xmlrpc_port = 8069
# runtime
self.pid = os.getpid()
def close_socket(self, sock): #反正就是关闭套接字啰
""" Closes a socket instance cleanly
:param sock: the network socket to close
:type sock: socket.socket
"""
try:
sock.shutdown(socket.SHUT_RDWR)
except socket.error, e:
if e.errno == errno.EBADF:
# Werkzeug > 0.9.6 closes the socket itself (see commit
# https://github.com/mitsuhiko/werkzeug/commit/4d8ca089)
return
# On OSX, socket shutdowns both sides if any side closes it
# causing an error 57 'Socket is not connected' on shutdown
# of the other side (or something), see
# http://bugs.python.org/issue4397
# note: stdlib fixed test, not behavior
if e.errno != errno.ENOTCONN or platform.system() not in ['Darwin', 'Windows']:
raise
sock.close()
由于我的配置中使用的是threaded&#