本文整理汇总了Python中syncdutils.finalize函数的典型用法代码示例。如果您正苦于以下问题:Python finalize函数的具体用法?Python finalize怎么用?Python finalize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了finalize函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: wmon
def wmon(w):
cpid, _ = self.monitor(w, argv, cpids)
time.sleep(1)
self.lock.acquire()
for cpid in cpids:
os.kill(cpid, signal.SIGKILL)
self.lock.release()
finalize(exval=1)
开发者ID:humblec,项目名称:glusterfs,代码行数:8,代码来源:monitor.py
示例2: errfail
def errfail(self):
"""fail nicely if child did not terminate with success"""
filling = ""
if self.elines:
filling = ", saying:"
logging.error("""command "%s" returned with %s%s""" % (" ".join(self.args), repr(self.returncode), filling))
for l in self.elines:
for ll in l.rstrip().split("\n"):
logging.error(self.args[0] + "> " + ll.rstrip())
syncdutils.finalize(exval=1)
开发者ID:rambhatm,项目名称:glusterfs,代码行数:10,代码来源:resource.py
示例3: wmon
def wmon(w):
cpid, _ = self.monitor(w, argv, cpids, agents, slave_vol,
slave_host)
time.sleep(1)
self.lock.acquire()
for cpid in cpids:
os.kill(cpid, signal.SIGKILL)
for apid in agents:
os.kill(apid, signal.SIGKILL)
self.lock.release()
finalize(exval=1)
开发者ID:rootfs,项目名称:glusterfs,代码行数:11,代码来源:monitor.py
示例4: wmon
def wmon(w):
cpid, _ = self.monitor(w, argv, cpids, agents, slave_vol,
slave_host, master)
time.sleep(1)
self.lock.acquire()
for cpid in cpids:
errno_wrap(os.kill, [cpid, signal.SIGKILL], [ESRCH])
for apid in agents:
errno_wrap(os.kill, [apid, signal.SIGKILL], [ESRCH])
self.lock.release()
finalize(exval=1)
开发者ID:Byreddys,项目名称:glusterfs,代码行数:11,代码来源:monitor.py
示例5: main
def main():
signal.signal(signal.SIGTERM, lambda *a: finalize(*a, **{'exval': 1}))
GLogger.setup()
excont = FreeObject(exval = 0)
try:
try:
main_i()
except:
log_raise_exception(excont)
finally:
finalize(exval = excont.exval)
开发者ID:vbellur,项目名称:glusterfs,代码行数:11,代码来源:gsyncd.py
示例6: main
def main():
"""main routine, signal/exception handling boilerplates"""
signal.signal(signal.SIGTERM, lambda *a: finalize(*a, **{'exval': 1}))
GLogger.setup()
excont = FreeObject(exval = 0)
try:
try:
main_i()
except:
log_raise_exception(excont)
finally:
finalize(exval = excont.exval)
开发者ID:Dhandapani,项目名称:glusterfs,代码行数:12,代码来源:gsyncd.py
示例7: main
def main():
"""main routine, signal/exception handling boilerplates"""
gconf.starttime = time.time()
set_term_handler()
GLogger.setup()
excont = FreeObject(exval = 0)
try:
try:
main_i()
except:
log_raise_exception(excont)
finally:
finalize(exval = excont.exval)
开发者ID:Anna-Miya-Dan,项目名称:glusterfs,代码行数:13,代码来源:gsyncd.py
示例8: service_loop
def service_loop(self):
"""start a RePCe server serving self's server
stop servicing if a timeout is configured and got no
keep-alime in that inteval
"""
if boolify(gconf.use_rsync_xattrs) and not privileged():
raise GsyncdError(
"using rsync for extended attributes is not supported")
repce = RepceServer(
self.server, sys.stdin, sys.stdout, int(gconf.sync_jobs))
t = syncdutils.Thread(target=lambda: (repce.service_loop(),
syncdutils.finalize()))
t.start()
logging.info("slave listening")
if gconf.timeout and int(gconf.timeout) > 0:
while True:
lp = self.server.last_keep_alive
time.sleep(int(gconf.timeout))
if lp == self.server.last_keep_alive:
logging.info(
"connection inactive for %d seconds, stopping" %
int(gconf.timeout))
break
else:
select((), (), ())
开发者ID:humblec,项目名称:glusterfs,代码行数:28,代码来源:resource.py
示例9: __init__
def __init__(self, obj, fd_tup):
(inf, ouf, rw, ww) = fd_tup.split(',')
repce = RepceServer(obj, int(inf), int(ouf), 1)
t = syncdutils.Thread(target=lambda: (repce.service_loop(),
syncdutils.finalize()))
t.start()
logging.info('Agent listining...')
select((), (), ())
开发者ID:Apekhsha,项目名称:glusterfs,代码行数:9,代码来源:changelogagent.py
示例10: service_loop
def service_loop(self):
repce = RepceServer(self.server, sys.stdin, sys.stdout, int(gconf.sync_jobs))
t = syncdutils.Thread(target=lambda: (repce.service_loop(),
syncdutils.finalize()))
t.start()
logging.info("slave listening")
if gconf.timeout and int(gconf.timeout) > 0:
while True:
lp = self.server.last_keep_alive
time.sleep(int(gconf.timeout))
if lp == self.server.last_keep_alive:
logging.info("connection inactive for %d seconds, stopping" % int(gconf.timeout))
break
else:
select.select((), (), ())
开发者ID:vbellur,项目名称:glusterfs,代码行数:15,代码来源:resource.py
示例11: service_loop
def service_loop(self):
"""start a RePCe server serving self's server
stop servicing if a timeout is configured and got no
keep-alime in that inteval
"""
repce = RepceServer(self.server, sys.stdin, sys.stdout, int(gconf.sync_jobs))
t = syncdutils.Thread(target=lambda: (repce.service_loop(), syncdutils.finalize()))
t.start()
logging.info("slave listening")
if gconf.timeout and int(gconf.timeout) > 0:
while True:
lp = self.server.last_keep_alive
time.sleep(int(gconf.timeout))
if lp == self.server.last_keep_alive:
logging.info("connection inactive for %d seconds, stopping" % int(gconf.timeout))
break
else:
select((), (), ())
开发者ID:rambhatm,项目名称:glusterfs,代码行数:19,代码来源:resource.py
示例12: inhibit
def inhibit(self, *a):
"""inhibit a gluster filesystem
Mount glusterfs over a temporary mountpoint,
change into the mount, and lazy unmount the
filesystem.
"""
mpi, mpo = os.pipe()
mh = Popen.fork()
if mh:
os.close(mpi)
fcntl.fcntl(mpo, fcntl.F_SETFD, fcntl.FD_CLOEXEC)
d = None
margv = self.make_mount_argv(*a)
if self.mntpt:
# mntpt is determined pre-mount
d = self.mntpt
os.write(mpo, d + '\0')
po = Popen(margv, **self.mountkw)
self.handle_mounter(po)
po.terminate_geterr()
logging.debug('auxiliary glusterfs mount in place')
if not d:
# mntpt is determined during mount
d = self.mntpt
os.write(mpo, d + '\0')
os.write(mpo, 'M')
t = syncdutils.Thread(target=lambda: os.chdir(d))
t.start()
tlim = gconf.starttime + int(gconf.connection_timeout)
while True:
if not t.isAlive():
break
if time.time() >= tlim:
syncdutils.finalize(exval = 1)
time.sleep(1)
os.close(mpo)
_, rv = syncdutils.waitpid(mh, 0)
if rv:
rv = (os.WIFEXITED(rv) and os.WEXITSTATUS(rv) or 0) - \
(os.WIFSIGNALED(rv) and os.WTERMSIG(rv) or 0)
logging.warn('stale mount possibly left behind on ' + d)
raise GsyncdError("cleaning up temp mountpoint %s failed with status %d" % \
(d, rv))
else:
rv = 0
try:
os.setsid()
os.close(mpo)
mntdata = ''
while True:
c = os.read(mpi, 1)
if not c:
break
mntdata += c
if mntdata:
mounted = False
if mntdata[-1] == 'M':
mntdata = mntdata[:-1]
assert(mntdata)
mounted = True
assert(mntdata[-1] == '\0')
mntpt = mntdata[:-1]
assert(mntpt)
if mounted:
po = self.umount_l(mntpt)
po.terminate_geterr(fail_on_err = False)
if po.returncode != 0:
po.errlog()
rv = po.returncode
self.cleanup_mntpt(mntpt)
except:
logging.exception('mount cleanup failure:')
rv = 200
os._exit(rv)
logging.debug('auxiliary glusterfs mount prepared')
开发者ID:ArikaChen,项目名称:glusterfs,代码行数:77,代码来源:resource.py
示例13: errfail
def errfail(self):
"""fail nicely if child did not terminate with success"""
self.errlog()
syncdutils.finalize(exval = 1)
开发者ID:ArikaChen,项目名称:glusterfs,代码行数:4,代码来源:resource.py
示例14: main
#.........这里部分代码省略.........
# Subcmd accepts config file argument but not passed
# Set default path for config file in that case
# If an subcmd accepts config file then it also accepts
# master and Slave arguments.
if config_file is None and hasattr(args, "config_file"):
config_file = "%s/geo-replication/%s_%s_%s/gsyncd.conf" % (
GLUSTERD_WORKDIR,
args.master,
extra_tmpl_args["primary_slave_host"],
extra_tmpl_args["slavevol"])
# If Config file path not exists, log error and continue using default conf
config_file_error_msg = None
if config_file is not None and not os.path.exists(config_file):
# Logging not yet initialized, create the error message to
# log later and reset the config_file to None
config_file_error_msg = lf(
"Session config file not exists, using the default config",
path=config_file)
config_file = None
rconf.config_file = config_file
# Override gconf values from argument values only if it is slave gsyncd
override_from_args = False
if args.subcmd == "slave":
override_from_args = True
# Load Config file
gconf.load(GLUSTERFS_CONFDIR + "/gsyncd.conf",
config_file,
vars(args),
extra_tmpl_args,
override_from_args)
# Default label to print in log file
label = args.subcmd
if args.subcmd in ("worker", "agent"):
# If Worker or agent, then add brick path also to label
label = "%s %s" % (args.subcmd, args.local_path)
elif args.subcmd == "slave":
# If Slave add Master node and Brick details
label = "%s %s%s" % (args.subcmd, args.master_node, args.master_brick)
# Setup Logger
# Default log file
log_file = gconf.get("cli-log-file")
log_level = gconf.get("cli-log-level")
if getattr(args, "master", None) is not None and \
getattr(args, "slave", None) is not None:
log_file = gconf.get("log-file")
log_level = gconf.get("log-level")
# Use different log file location for Slave log file
if args.subcmd == "slave":
log_file = gconf.get("slave-log-file")
log_level = gconf.get("slave-log-level")
if args.debug:
log_file = "-"
log_level = "DEBUG"
# Create Logdir if not exists
try:
if log_file != "-":
os.mkdir(os.path.dirname(log_file))
except OSError as e:
if e.errno != EEXIST:
raise
setup_logging(
log_file=log_file,
level=log_level,
label=label
)
if config_file_error_msg is not None:
logging.warn(config_file_error_msg)
# Log message for loaded config file
if config_file is not None:
logging.info(lf("Using session config file", path=config_file))
set_term_handler()
excont = FreeObject(exval=0)
# Gets the function name based on the input argument. For example
# if subcommand passed as argument is monitor then it looks for
# function with name "subcmd_monitor" in subcmds file
func = getattr(subcmds, "subcmd_" + args.subcmd.replace("-", "_"), None)
try:
try:
if func is not None:
rconf.args = args
func(args)
except:
log_raise_exception(excont)
finally:
finalize(exval=excont.exval)
开发者ID:gluster,项目名称:glusterfs,代码行数:101,代码来源:gsyncd.py
注:本文中的syncdutils.finalize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论