Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discard master-slave phrasing #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions lib/python3.6/site-packages/gunicorn/arbiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def __init__(self, app):
self.systemd = False
self.worker_age = 0
self.reexec_pid = 0
self.master_pid = 0
self.master_name = "Master"
self.main_pid = 0
self.main_name = "Main"

cwd = util.getcwd()

Expand Down Expand Up @@ -126,14 +126,14 @@ def start(self):
self.log.info("Starting gunicorn %s", __version__)

if 'GUNICORN_PID' in os.environ:
self.master_pid = int(os.environ.get('GUNICORN_PID'))
self.main_pid = int(os.environ.get('GUNICORN_PID'))
self.proc_name = self.proc_name + ".2"
self.master_name = "Master.2"
self.main_name = "Main.2"

self.pid = os.getpid()
if self.cfg.pidfile is not None:
pidname = self.cfg.pidfile
if self.master_pid != 0:
if self.main_pid != 0:
pidname += ".2"
self.pidfile = Pidfile(pidname)
self.pidfile.create(self.pid)
Expand All @@ -149,7 +149,7 @@ def start(self):
fds = range(systemd.SD_LISTEN_FDS_START,
systemd.SD_LISTEN_FDS_START + listen_fds)

elif self.master_pid:
elif self.main_pid:
fds = []
for fd in os.environ.pop('GUNICORN_FD').split(','):
fds.append(int(fd))
Expand All @@ -169,8 +169,8 @@ def start(self):

def init_signals(self):
"""\
Initialize master signal handling. Most of the signals
are queued. Child signals only wake up the master.
Initialize main signal handling. Most of the signals
are queued. Child signals only wake up the main.
"""
# close old PIPE
for p in self.PIPE:
Expand All @@ -195,15 +195,15 @@ def signal(self, sig, frame):
self.wakeup()

def run(self):
"Main master loop."
"Main main loop."
self.start()
util._setproctitle("master [%s]" % self.proc_name)
util._setproctitle("main [%s]" % self.proc_name)

try:
self.manage_workers()

while True:
self.maybe_promote_master()
self.maybe_promote_main()

sig = self.SIG_QUEUE.pop(0) if self.SIG_QUEUE else None
if sig is None:
Expand Down Expand Up @@ -252,7 +252,7 @@ def handle_hup(self):
- Start the new worker processes with a new configuration
- Gracefully shutdown the old worker processes
"""
self.log.info("Hang up: %s", self.master_name)
self.log.info("Hang up: %s", self.main_name)
self.reload()

def handle_term(self):
Expand Down Expand Up @@ -298,8 +298,8 @@ def handle_usr1(self):
def handle_usr2(self):
"""\
SIGUSR2 handling.
Creates a new master/worker set as a slave of the current
master without affecting old workers. Use this to do live
Creates a new main/worker set as a subordinate of the current
main without affecting old workers. Use this to do live
deployment with the ability to backout a change.
"""
self.reexec()
Expand All @@ -313,22 +313,22 @@ def handle_winch(self):
else:
self.log.debug("SIGWINCH ignored. Not daemonized")

def maybe_promote_master(self):
if self.master_pid == 0:
def maybe_promote_main(self):
if self.main_pid == 0:
return

if self.master_pid != os.getppid():
self.log.info("Master has been promoted.")
# reset master infos
self.master_name = "Master"
self.master_pid = 0
if self.main_pid != os.getppid():
self.log.info("Main has been promoted.")
# reset main infos
self.main_name = "Main"
self.main_pid = 0
self.proc_name = self.cfg.proc_name
del os.environ['GUNICORN_PID']
# rename the pidfile
if self.pidfile is not None:
self.pidfile.rename(self.cfg.pidfile)
# reset proctitle
util._setproctitle("master [%s]" % self.proc_name)
util._setproctitle("main [%s]" % self.proc_name)

def wakeup(self):
"""\
Expand All @@ -343,7 +343,7 @@ def wakeup(self):
def halt(self, reason=None, exit_status=0):
""" halt arbiter """
self.stop()
self.log.info("Shutting down: %s", self.master_name)
self.log.info("Shutting down: %s", self.main_name)
if reason is not None:
self.log.info("Reason: %s", reason)
if self.pidfile is not None:
Expand Down Expand Up @@ -378,7 +378,7 @@ def stop(self, graceful=True):
killed gracefully (ie. trying to wait for the current connection)
"""

unlink = self.reexec_pid == self.master_pid == 0 and not self.systemd
unlink = self.reexec_pid == self.main_pid == 0 and not self.systemd
sock.close_sockets(self.LISTENERS, unlink)

self.LISTENERS = []
Expand All @@ -396,25 +396,25 @@ def stop(self, graceful=True):

def reexec(self):
"""\
Relaunch the master and workers.
Relaunch the main and workers.
"""
if self.reexec_pid != 0:
self.log.warning("USR2 signal ignored. Child exists.")
return

if self.master_pid != 0:
if self.main_pid != 0:
self.log.warning("USR2 signal ignored. Parent exists.")
return

master_pid = os.getpid()
main_pid = os.getpid()
self.reexec_pid = os.fork()
if self.reexec_pid != 0:
return

self.cfg.pre_exec(self)

environ = self.cfg.env_orig.copy()
environ['GUNICORN_PID'] = str(master_pid)
environ['GUNICORN_PID'] = str(main_pid)

if self.systemd:
environ['LISTEN_PID'] = str(os.getpid())
Expand Down Expand Up @@ -474,7 +474,7 @@ def reload(self):
self.pidfile.create(self.pid)

# set new proc_name
util._setproctitle("master [%s]" % self.proc_name)
util._setproctitle("main [%s]" % self.proc_name)

# spawn new workers
for _ in range(self.cfg.workers):
Expand Down Expand Up @@ -609,7 +609,7 @@ def spawn_workers(self):
Spawn new workers as needed.

This is where a worker process leaves the main loop
of the master process.
of the main process.
"""

for _ in range(self.num_workers - len(self.WORKERS.keys())):
Expand Down
6 changes: 3 additions & 3 deletions lib/python3.6/site-packages/gunicorn/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,7 +1547,7 @@ def on_starting(server):
pass
default = staticmethod(on_starting)
desc = """\
Called just before the master process is initialized.
Called just before the main process is initialized.

The callable needs to accept a single instance variable for the Arbiter.
"""
Expand Down Expand Up @@ -1684,7 +1684,7 @@ def pre_exec(server):
pass
default = staticmethod(pre_exec)
desc = """\
Called just before a new master process is forked.
Called just before a new main process is forked.

The callable needs to accept a single instance variable for the Arbiter.
"""
Expand Down Expand Up @@ -1734,7 +1734,7 @@ def child_exit(server, worker):
pass
default = staticmethod(child_exit)
desc = """\
Called just after a worker has been exited, in the master process.
Called just after a worker has been exited, in the main process.

The callable needs to accept two instance variables for the Arbiter and
the just-exited Worker.
Expand Down
2 changes: 1 addition & 1 deletion lib/python3.6/site-packages/gunicorn/workers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def notify(self):
"""\
Your worker subclass must arrange to have this method called
once every ``self.timeout`` seconds. If you fail in accomplishing
this task, the master process will murder your workers.
this task, the main process will murder your workers.
"""
self.tmp.notify()

Expand Down
2 changes: 1 addition & 1 deletion lib/python3.6/site-packages/mysql/connector/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ class RefreshOption(_Constants):
'HOSTS': (1 << 3, 'Flush host cache'),
'STATUS': (1 << 4, 'Flush status variables'),
'THREADS': (1 << 5, 'Flush thread cache'),
'SLAVE': (1 << 6, 'Reset master info and restart slave thread'),
'SLAVE': (1 << 6, 'Reset main info and restart subordinate thread'),
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
CR_EMBEDDED_CONNECTION = u"Embedded server"
CR_PROBE_SLAVE_STATUS = u"Error on SHOW SLAVE STATUS:"
CR_PROBE_SLAVE_HOSTS = u"Error on SHOW SLAVE HOSTS:"
CR_PROBE_SLAVE_CONNECT = u"Error connecting to slave:"
CR_PROBE_MASTER_CONNECT = u"Error connecting to master:"
CR_PROBE_SLAVE_CONNECT = u"Error connecting to subordinate:"
CR_PROBE_MASTER_CONNECT = u"Error connecting to main:"
CR_SSL_CONNECTION_ERROR = u"SSL connection error: %-.100s"
CR_MALFORMED_PACKET = u"Malformed packet"
CR_WRONG_LICENSE = u"This client library is licensed only for use with MySQL servers having '%s' license"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
CR_EMBEDDED_CONNECTION = u"Embedded server"
CR_PROBE_SLAVE_STATUS = u"Error on SHOW SLAVE STATUS:"
CR_PROBE_SLAVE_HOSTS = u"Error on SHOW SLAVE HOSTS:"
CR_PROBE_SLAVE_CONNECT = u"Error connecting to slave:"
CR_PROBE_MASTER_CONNECT = u"Error connecting to master:"
CR_PROBE_SLAVE_CONNECT = u"Error connecting to subordinate:"
CR_PROBE_MASTER_CONNECT = u"Error connecting to main:"
CR_SSL_CONNECTION_ERROR = u"SSL connection error: %-.100s"
CR_MALFORMED_PACKET = u"Malformed packet"
CR_WRONG_LICENSE = u"This client library is licensed only for use with MySQL servers having '%s' license"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,9 @@ def __init__(self, entries=None):
self.add_entry(entry)

@classmethod
def _build_master(cls):
def _build_main(cls):
"""
Prepare the master working set.
Prepare the main working set.
"""
ws = cls()
try:
Expand Down Expand Up @@ -3016,9 +3016,9 @@ def _initialize(g=globals()):


@_call_aside
def _initialize_master_working_set():
def _initialize_main_working_set():
"""
Prepare the master working set and make the ``require()``
Prepare the main working set and make the ``require()``
API available.

This function has explicit effects on the global state
Expand All @@ -3028,7 +3028,7 @@ def _initialize_master_working_set():
Invocation by other packages is unsupported and done
at their own risk.
"""
working_set = WorkingSet._build_master()
working_set = WorkingSet._build_main()
_declare_state('object', working_set=working_set)

require = working_set.require
Expand Down
4 changes: 2 additions & 2 deletions lib/python3.6/site-packages/pip/vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def update(self, dest, rev_options):
self.run_command(['fetch', '-q', '--tags'], cwd=dest)
else:
self.run_command(['fetch', '-q'], cwd=dest)
# Then reset to wanted revision (maybe even origin/master)
# Then reset to wanted revision (maybe even origin/main)
if rev_options:
rev_options = self.check_rev_options(
rev_options[0], dest, rev_options,
Expand All @@ -133,7 +133,7 @@ def obtain(self, dest):
rev_options = [rev]
rev_display = ' (to %s)' % rev
else:
rev_options = ['origin/master']
rev_options = ['origin/main']
rev_display = ''
if self.check_destination(dest, url, rev_options, rev_display):
logger.info(
Expand Down
10 changes: 5 additions & 5 deletions lib/python3.6/site-packages/pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,9 @@ def __init__(self, entries=None):
self.add_entry(entry)

@classmethod
def _build_master(cls):
def _build_main(cls):
"""
Prepare the master working set.
Prepare the main working set.
"""
ws = cls()
try:
Expand Down Expand Up @@ -3015,9 +3015,9 @@ def _initialize(g=globals()):


@_call_aside
def _initialize_master_working_set():
def _initialize_main_working_set():
"""
Prepare the master working set and make the ``require()``
Prepare the main working set and make the ``require()``
API available.

This function has explicit effects on the global state
Expand All @@ -3027,7 +3027,7 @@ def _initialize_master_working_set():
Invocation by other packages is unsupported and done
at their own risk.
"""
working_set = WorkingSet._build_master()
working_set = WorkingSet._build_main()
_declare_state('object', working_set=working_set)

require = working_set.require
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ def update_dist_caches(dist_path, fix_zipimporter_caches):
# There are several other known sources of stale zipimport.zipimporter
# instances that we do not clear here, but might if ever given a reason to
# do so:
# * Global setuptools pkg_resources.working_set (a.k.a. 'master working
# * Global setuptools pkg_resources.working_set (a.k.a. 'main working
# set') may contain distributions which may in turn contain their
# zipimport.zipimporter loaders.
# * Several zipimport.zipimporter loaders held by local variables further
Expand Down