本文整理汇总了Python中signal.pause函数的典型用法代码示例。如果您正苦于以下问题:Python pause函数的具体用法?Python pause怎么用?Python pause使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pause函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
port = common.PORT
username = input("Choose a username : ")
dark_vader, luke = Pipe()
p = Process(target=server_process, args=(luke, port, username))
p.start()
def pause_handler(signum, frame):
pass
def chat_handler(signum, frame):
print(u'\033[2K\n\033[1A',end='', flush=True)
print(dark_vader.recv())
print('{} > '.format(username), end="", flush=True)
signal.signal(41, pause_handler)
signal.signal(42, chat_handler)
signal.pause()
chat.chat(port, username)
p.terminate()
开发者ID:vabic,项目名称:l33tnet,代码行数:26,代码来源:main.py
示例2: reap
def reap(self):
"""Collect the dead jobs."""
while self._running:
dead = set()
for job in self._running:
st = job.state(self._cache)
if st == _RUNNING: continue
if st == _FAILURE or st == _KILLED:
self._failures += 1
if self._stop_on_failure:
self._cancelled = True
for job in self._running:
job.kill()
dead.add(job)
break
for job in dead:
self._completed += 1
self._running.remove(job)
if dead: return
if (not self._travis):
message('WAITING', '%d jobs running, %d complete, %d failed' % (
len(self._running), self._completed, self._failures))
if platform.system() == 'Windows':
time.sleep(0.1)
else:
global have_alarm
if not have_alarm:
have_alarm = True
signal.alarm(10)
signal.pause()
开发者ID:quirkey,项目名称:grpc,代码行数:30,代码来源:jobset.py
示例3: main
def main():
god = God(paper=PAPER)
god.setup()
god.start()
signal.pause()
god.world()
开发者ID:shockjiang,项目名称:ndnflow,代码行数:7,代码来源:consumers_kit.py
示例4: test_signals
def test_signals(self):
# Test signal handling semantics of threads.
# We spawn a thread, have the thread send two signals, and
# wait for it to finish. Check that we got both signals
# and that they were run by the main thread.
signalled_all.acquire()
self.spawnSignallingThread()
signalled_all.acquire()
# the signals that we asked the kernel to send
# will come back, but we don't know when.
# (it might even be after the thread exits
# and might be out of order.) If we haven't seen
# the signals yet, send yet another signal and
# wait for it return.
if signal_blackboard[signal.SIGUSR1]['tripped'] == 0 \
or signal_blackboard[signal.SIGUSR2]['tripped'] == 0:
signal.alarm(1)
signal.pause()
signal.alarm(0)
self.assertEqual( signal_blackboard[signal.SIGUSR1]['tripped'], 1)
self.assertEqual( signal_blackboard[signal.SIGUSR1]['tripped_by'],
thread.get_ident())
self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped'], 1)
self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped_by'],
thread.get_ident())
signalled_all.release()
开发者ID:pombredanne,项目名称:cpython,代码行数:27,代码来源:test_threadsignals.py
示例5: test_sigchld
def test_sigchld():
r = reaper.Reaper()
old_sigchld = signal.getsignal(signal.SIGCHLD)
r.hookup_sigchld()
assert r.old_sigchld is old_sigchld
assert signal.getsignal(signal.SIGCHLD) == reaper.theReaper.handle_sigchld
del r
waiting = [DelayedExitFork(i, (i % 32) / 32) for i in range(256)]
while waiting:
signal.pause()
i = 0
while i < len(waiting):
if waiting[i].obit is not None:
f = waiting.pop(i)
assert f.obit.pid == f.pid
assert f.obit.exitstatus == f.expectedstatus
assert f.obit.termsig is None
assert f.obit.stopsig is None
assert f.obit.coredump is False
else:
i += 1
reaper.theReaper.unhookup_sigchld()
assert signal.getsignal(signal.SIGCHLD) is old_sigchld
reaper.theReaper = None
开发者ID:jcorbin,项目名称:better-subprocess,代码行数:27,代码来源:test_reaper.py
示例6: withEmpty
def withEmpty(words):
start = time.time()
for w in words:
pass
print '%fs' % (time.time() - start)
signal.pause()
开发者ID:GHScan,项目名称:DailyProjects,代码行数:7,代码来源:interning.py
示例7: main
def main(self):
# See comment at top of file about zuul imports
import zuul.scheduler
import zuul.launcher.jenkins
import zuul.trigger.gerrit
self.sched = zuul.scheduler.Scheduler()
jenkins = zuul.launcher.jenkins.Jenkins(self.config, self.sched)
gerrit = zuul.trigger.gerrit.Gerrit(self.config, self.sched)
self.sched.setLauncher(jenkins)
self.sched.setTrigger(gerrit)
self.sched.start()
self.sched.reconfigure(self.config)
self.sched.resume()
signal.signal(signal.SIGHUP, self.reconfigure_handler)
signal.signal(signal.SIGUSR1, self.exit_handler)
while True:
try:
signal.pause()
except KeyboardInterrupt:
print "Ctrl + C: asking scheduler to exit nicely...\n"
self.exit_handler(signal.SIGINT, None)
开发者ID:bodepd,项目名称:zuul,代码行数:25,代码来源:server.py
示例8: main
def main():
syncilainen = None
def reload(signum, stack):
if syncilainen:
syncilainen.reload_config()
def quit(signum, stack):
if syncilainen:
syncilainen.stop()
exit(0)
# listen for SIGHUP or SIGUSR1 and reload config
signal.signal(signal.SIGHUP, reload)
signal.signal(signal.SIGUSR1, reload)
# listen for SIGINT and quit gracefully
signal.signal(signal.SIGINT, quit)
# boilerplate
options = read_options()
setup_logging(options.log_file, options.debug)
logging.info("PID: %s" % os.getpid())
# start the syncilainen daemon
syncilainen = Syncilainen()
syncilainen.start()
# wait for signals
while True:
signal.pause()
开发者ID:konker,项目名称:syncilainen,代码行数:32,代码来源:syncilainen.py
示例9: main
def main(self):
self.setup_logging()
self.pool = nodepool.nodepool.NodePool(self.args.secure,
self.args.config,
self.args.no_deletes,
self.args.no_launches,
self.args.no_images)
if self.args.builder:
self.builder = nodepool.builder.NodePoolBuilder(
self.args.config, self.args.build_workers,
self.args.upload_workers)
if not self.args.no_webapp:
self.webapp = nodepool.webapp.WebApp(self.pool)
signal.signal(signal.SIGINT, self.exit_handler)
# For back compatibility:
signal.signal(signal.SIGUSR1, self.exit_handler)
signal.signal(signal.SIGUSR2, stack_dump_handler)
signal.signal(signal.SIGTERM, self.term_handler)
self.pool.start()
if self.args.builder:
nb_thread = threading.Thread(target=self.builder.runForever)
nb_thread.start()
if not self.args.no_webapp:
self.webapp.start()
while True:
signal.pause()
开发者ID:a10networks-ci,项目名称:nodepool,代码行数:32,代码来源:nodepoold.py
示例10: serve_forever
def serve_forever(host, port, childnum):
# create, bind, listen
listen_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# re-use the port
listen_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listen_sock.bind((host, port))
listen_sock.listen(BACKLOG)
print 'Listening on port %d ...' % port
global MAP
MAP = create_array(childnum)
# prefork children
global PIDS
PIDS = [create_child(index, listen_sock) for index in range(childnum)]
# setup SIGTERM handler - in case the parent is killed
signal.signal(signal.SIGTERM, _cleanup)
# parent never calls 'accept' - children do all the work
# all parent does is sleeping :)
try:
signal.pause()
except KeyboardInterrupt:
_exit_handler()
print_stats()
开发者ID:aiwagan,项目名称:csdesign,代码行数:28,代码来源:server03a.py
示例11: stop
def stop(self):
"""Shutdown the MCP and child processes cleanly"""
LOGGER.info('Shutting down controller')
self.set_state(self.STATE_STOP_REQUESTED)
# Clear out the timer
signal.setitimer(signal.ITIMER_PROF, 0, 0)
self._mcp.stop_processes()
if self._mcp.is_running:
LOGGER.info('Waiting up to 3 seconds for MCP to shut things down')
signal.setitimer(signal.ITIMER_REAL, 3, 0)
signal.pause()
LOGGER.info('Post pause')
# Force MCP to stop
if self._mcp.is_running:
LOGGER.warning('MCP is taking too long, requesting process kills')
self._mcp.stop_processes()
del self._mcp
else:
LOGGER.info('MCP exited cleanly')
# Change our state
self._stopped()
LOGGER.info('Shutdown complete')
开发者ID:gmr,项目名称:rejected,代码行数:27,代码来源:controller.py
示例12: start
def start(self):
# Watch the source files for changes
filewatch = Observer()
filewatch.schedule(FilewatchHandler(parent=self,
ignore_patterns=['*.swp', '*~']),
self.src_dir,
recursive=True)
# Clean shutdown on ctrl+c
def signal_handler(signal, frame):
print
print 'Shutting down...'
self.stop_server()
filewatch.stop()
signal.signal(signal.SIGINT, signal_handler)
self.rebuild()
self.start_server()
print 'Serving at port', self.port
print 'Serving files from', self.final_build_dir
print('Press Ctrl+C to stop')
filewatch.start()
signal.pause()
filewatch.join(5000)
开发者ID:undefinedvalue,项目名称:lucidblue,代码行数:27,代码来源:server.py
示例13: main
def main():
threads=[]
t = threading.Thread(
target=sniff,
kwargs={'prn':arp_handler, 'filter':'arp', 'iface': iface_name, 'store': 0},
name='ARP'
)
threads.append(t)
t = threading.Thread(
target=sniff,
kwargs={'prn':icmp_handler, 'filter':'icmp', 'iface': iface_name, 'store': 0},
name='ICMP'
)
threads.append(t)
for worker in threads:
worker.daemon=True
print "%s worker starting" % (worker.name)
worker.start()
try:
while (42):
time.sleep(1)
signal.pause()
except KeyboardInterrupt:
print "CTRL+C caught"
for worker in threads:
print "%s worker joining main thread" % (worker.name)
worker.join(1)
sys.exit(0)
开发者ID:LucianoKendz,项目名称:scapy,代码行数:34,代码来源:ministack.py
示例14: reap
def reap(self):
"""Collect the dead jobs."""
while self._running:
dead = set()
for job in self._running:
st = job.state(self._cache)
if st == _RUNNING:
continue
if st == _FAILURE:
self._failures += 1
if st == _KILLED:
self._failures += 1
dead.add(job)
for job in dead:
self._completed += 1
self._running.remove(job)
if dead:
return
if not self._travis:
message(
"WAITING",
"%d jobs running, %d complete, %d failed" % (len(self._running), self._completed, self._failures),
)
global have_alarm
if not have_alarm:
have_alarm = True
signal.alarm(10)
signal.pause()
开发者ID:qioixiy,项目名称:grpc,代码行数:28,代码来源:jobset.py
示例15: main
def main():
processes = {}
create_ugc_directories()
def restart(*args, **kwargs):
for app, proc in processes.items():
if proc:
print 'killing %s (%s)...' % (app, proc.pid)
proc.terminate()
proc.communicate()
if 'sass' in run('which sass', stdout=subprocess.PIPE).stdout.read():
sass()
redis()
memcache()
nginx()
for app in processes.keys():
processes[app] = globals()[app]()
print '%s: %s' % (app, processes[app].pid if processes[app] else None)
print 'All systems go! Ctrl+C to restart everything, Ctrl+Z to end.\n'
restart()
signal.signal(signal.SIGINT, restart)
while True:
signal.pause()
开发者ID:MichaelBechHansen,项目名称:drawquest-web,代码行数:27,代码来源:local.py
示例16: main
def main(args):
print "ufora-worker starting"
setup = defaultSetup()
with Setup.PushSetup(setup):
setup.config.configureLoggingForBackgroundProgram()
worker = createService(args)
worker.startService(None)
def signal_handler(sig, _):
signal_name = '(unknown)'
if sig == signal.SIGINT:
signal_name = 'SIGINT'
elif sig == signal.SIGTERM:
signal_name = 'SIGTERM'
print 'Received ', signal_name, 'signal. Exiting.'
worker.stopService()
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
print "Press Ctrl+C to exit."
signal.pause()
开发者ID:ufora,项目名称:ufora,代码行数:25,代码来源:ufora-worker.py
示例17: run_process
def run_process(child_id, test_file=None):
def send(msg):
sys.stdout.write('{0}:{1}\n'.format(child_id, msg))
sys.stdout.flush()
names = {}
signals = "HUP QUIT INT TERM USR1 USR2".split()
exit_signals = set("INT TERM".split())
children = []
if not isinstance(child_id, int):
child_id = 0
for i in range(3):
p = multiprocessing.Process(target=run_process, args=(i + 1,))
p.daemon = True
p.start()
children.append(p)
def callback(sig, frame=None):
global exiting
name = names[sig]
send(name)
if name in exit_signals:
exiting = True
for signal_name in signals:
signum = getattr(signal, "SIG%s" % signal_name)
names[signum] = signal_name
signal.signal(signum, callback)
send('STARTED')
while not exiting:
signal.pause()
send('EXITING')
开发者ID:SEJeff,项目名称:circus,代码行数:34,代码来源:test_command_signal.py
示例18: run
def run(self):
"""When the consumer is ready to start running, kick off all of our
consumer consumers and then loop while we process messages.
"""
self.set_state(self.STATE_ACTIVE)
self.setup_consumers()
# Set the SIGCHLD handler for child creation errors
signal.signal(signal.SIGCHLD, self.on_sigchld)
# Set the SIGALRM handler for poll interval
signal.signal(signal.SIGALRM, self.on_timer)
# Kick off the poll timer
signal.setitimer(signal.ITIMER_REAL, self.poll_interval, 0)
# Loop for the lifetime of the app, pausing for a signal to pop up
while self.is_running:
if not self.is_sleeping:
self.set_state(self.STATE_SLEEPING)
signal.pause()
# Note we're exiting run
LOGGER.info('Exiting Master Control Program')
开发者ID:gmr,项目名称:rejected,代码行数:25,代码来源:mcp.py
示例19: main
def main():
port = common.PORT
username = input("Choose a username : ")
dark_vader, luke = Pipe()
p = Process(target=server_process, args=(luke, port, username))
p.start()
def pause_handler(signum, frame):
pass
def chat_handler(signum, frame):
print(u'\033[2K\n\033[1A',end='', flush=True)
print(dark_vader.recv())
print('{} > '.format(username), end="", flush=True)
signal.signal(41, pause_handler)
signal.signal(42, chat_handler)
signal.pause()
try:
chat.chat(port, username)
except (KeyboardInterrupt, SystemExit): # Handle the ctrl+c
chat.broadcast(port, chat.encode(username, '{} leaved the chat'.format(username), special=True))
print('*** Quitting ***')
p.terminate()
开发者ID:PhiBabin,项目名称:l33tnet,代码行数:30,代码来源:main.py
示例20: reap
def reap(self):
"""Collect the dead jobs."""
while self._running:
dead = set()
for job in self._running:
st = job.state(self._cache)
if st == _RUNNING: continue
if st == _FAILURE or st == _KILLED:
self._failures += 1
if self._stop_on_failure:
self._cancelled = True
for job in self._running:
job.kill()
dead.add(job)
break
for job in dead:
self._completed += 1
self.resultset[job.GetSpec().shortname].append(job.result)
self._running.remove(job)
if dead: return
if (not self._travis):
rstr = '' if self._remaining is None else '%d queued, ' % self._remaining
message('WAITING', '%s%d jobs running, %d complete, %d failed' % (
rstr, len(self._running), self._completed, self._failures))
if platform_string() == 'windows':
time.sleep(0.1)
else:
global have_alarm
if not have_alarm:
have_alarm = True
signal.alarm(10)
signal.pause()
开发者ID:kdkeyser,项目名称:grpc,代码行数:32,代码来源:jobset.py
注:本文中的signal.pause函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论