本文整理汇总了Python中circus.process.Process.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Process.stop方法的具体用法?Python Process.stop怎么用?Python Process.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circus.process.Process
的用法示例。
在下文中一共展示了Process.stop方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rlimits
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import stop [as 别名]
def test_rlimits(self):
script_file = self.get_tmpfile(RLIMIT)
output_file = self.get_tmpfile()
cmd = PYTHON
args = [script_file, output_file]
rlimits = {'nofile': 20,
'nproc': 20}
process = Process('test', cmd, args=args, rlimits=rlimits)
poll_for(output_file, 'END')
process.stop()
with open(output_file, 'r') as f:
output = {}
for line in f.readlines():
line = line.rstrip()
line = line.split('=', 1)
if len(line) != 2:
continue
limit, value = line
output[limit] = value
def srt2ints(val):
return [circus.py3compat.long(key) for key in val[1:-1].split(',')]
wanted = [circus.py3compat.long(20), circus.py3compat.long(20)]
self.assertEqual(srt2ints(output['NOFILE']), wanted)
self.assertEqual(srt2ints(output['NPROC']), wanted)
示例2: test_initgroups
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import stop [as 别名]
def test_initgroups(self):
cmd = sys.executable
args = [SLEEP % 2]
gid = os.getgid()
uid = os.getuid()
p1 = Process('1', cmd, args=args, gid=gid, uid=uid)
p1.stop()
示例3: test_rlimits
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import stop [as 别名]
def test_rlimits(self):
script_file = self.get_tmpfile(RLIMIT)
output_file = self.get_tmpfile()
cmd = sys.executable
args = [script_file, output_file]
rlimits = {'nofile': 20,
'nproc': 20}
process = Process('test', cmd, args=args, rlimits=rlimits)
try:
# wait for the process to finish
while process.status == RUNNING:
time.sleep(1)
finally:
process.stop()
with open(output_file, 'r') as f:
output = {}
for line in f.readlines():
limit, value = line.rstrip().split('=', 1)
output[limit] = value
def srt2ints(val):
return [circus.py3compat.long(key) for key in val[1:-1].split(',')]
wanted = [circus.py3compat.long(20), circus.py3compat.long(20)]
self.assertEqual(srt2ints(output['NOFILE']), wanted)
self.assertEqual(srt2ints(output['NPROC']), wanted)
示例4: test_initgroups
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import stop [as 别名]
def test_initgroups(self):
cmd = sys.executable
args = ['import time; time.sleep(2)']
gid = os.getgid()
uid = os.getuid()
p1 = Process('1', cmd, args=args, gid=gid, uid=uid)
p1.stop()
示例5: test_rlimits
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import stop [as 别名]
def test_rlimits(self):
script_file = self.get_tmpfile(RLIMIT)
output_file = self.get_tmpfile()
cmd = sys.executable
args = [script_file, output_file]
rlimits = {"nofile": 20, "nproc": 20}
process = Process("test", cmd, args=args, rlimits=rlimits)
poll_for(output_file, "END")
process.stop()
with open(output_file, "r") as f:
output = {}
for line in f.readlines():
line = line.rstrip()
line = line.split("=", 1)
if len(line) != 2:
continue
limit, value = line
output[limit] = value
def srt2ints(val):
return [circus.py3compat.long(key) for key in val[1:-1].split(",")]
wanted = [circus.py3compat.long(20), circus.py3compat.long(20)]
self.assertEqual(srt2ints(output["NOFILE"]), wanted)
self.assertEqual(srt2ints(output["NPROC"]), wanted)
示例6: test_base
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import stop [as 别名]
def test_base(self):
cmd = "%s -c 'import time; time.sleep(2)'"
process = Process('test', cmd % sys.executable, shell=True)
try:
info = process.info()
self.assertEqual(process.pid, info['pid'])
age = process.age()
self.assertTrue(age > 0.)
self.assertFalse(process.is_child(0))
finally:
process.stop()
示例7: test_comparison
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import stop [as 别名]
def test_comparison(self):
cmd = sys.executable
args = ['import time; time.sleep(2)', ]
p1 = Process('1', cmd, args=args)
p2 = Process('2', cmd, args=args)
self.assertTrue(p1 < p2)
self.assertFalse(p1 == p2)
self.assertTrue(p1 == p1)
p1.stop()
p2.stop()
示例8: test_base
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import stop [as 别名]
def test_base(self):
cmd = sys.executable
args = "-c 'import time; time.sleep(2)'"
process = Process("test", cmd, args=args, shell=False)
try:
info = process.info()
self.assertEqual(process.pid, info["pid"])
age = process.age()
self.assertTrue(age > 0.0)
self.assertFalse(process.is_child(0))
finally:
process.stop()
示例9: test_comparison
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import stop [as 别名]
def test_comparison(self):
cmd = PYTHON
args = ['import time; time.sleep(2)', ]
p1 = Process('1', cmd, args=args, use_fds=USE_FDS)
# Make sure the two processes are launched with a measurable
# difference. (precsion error on Windows)
time.sleep(0.01)
p2 = Process('2', cmd, args=args, use_fds=USE_FDS)
self.assertTrue(p1 < p2)
self.assertFalse(p1 == p2)
self.assertTrue(p1 == p1)
p1.stop()
p2.stop()
示例10: test_base
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import stop [as 别名]
def test_base(self):
cmd = PYTHON
args = "-c 'import time; time.sleep(10)'"
process = Process('test', cmd, args=args, shell=False,
use_fds=USE_FDS)
try:
info = process.info()
self.assertEqual(process.pid, info['pid'])
# Make sure the process lived a measurable amount of time
# (precision error on Windows)
time.sleep(0.01)
age = process.age()
self.assertTrue(age > 0.)
self.assertFalse(process.is_child(0))
finally:
process.stop()
示例11: test_streams
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import stop [as 别名]
def test_streams(self):
script_file = self.get_tmpfile(VERBOSE)
output_file = self.get_tmpfile()
cmd = sys.executable
args = [script_file, output_file]
# 1. streams sent to /dev/null
process = Process("test", cmd, args=args, close_child_stdout=True, close_child_stderr=True)
try:
poll_for(output_file, "END")
# the pipes should be empty
self.assertEqual(process.stdout.read(), b"")
self.assertEqual(process.stderr.read(), b"")
finally:
process.stop()
# 2. streams sent to /dev/null, no PIPEs
output_file = self.get_tmpfile()
args[1] = output_file
process = Process(
"test",
cmd,
args=args,
close_child_stdout=True,
close_child_stderr=True,
pipe_stdout=False,
pipe_stderr=False,
)
try:
poll_for(output_file, "END")
# the pipes should be unexistant
self.assertTrue(process.stdout is None)
self.assertTrue(process.stderr is None)
finally:
process.stop()
# 3. streams & pipes open
output_file = self.get_tmpfile()
args[1] = output_file
process = Process("test", cmd, args=args)
try:
poll_for(output_file, "END")
# the pipes should be unexistant
self.assertEqual(len(process.stdout.read()), 2890)
self.assertEqual(len(process.stderr.read()), 2890)
finally:
process.stop()
示例12: test_streams
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import stop [as 别名]
def test_streams(self):
script_file = self.get_tmpfile(VERBOSE)
cmd = sys.executable
args = [script_file]
# 1. streams sent to /dev/null
process = Process('test', cmd, args=args, close_child_stdout=True,
close_child_stderr=True)
try:
# wait for the process to finish
while process.status == RUNNING:
time.sleep(1)
# the pipes should be empty
self.assertEqual(process.stdout.read(), b'')
self.assertEqual(process.stderr.read(), b'')
finally:
process.stop()
# 2. streams sent to /dev/null, no PIPEs
process = Process('test', cmd, args=args, close_child_stdout=True,
close_child_stderr=True, pipe_stdout=False,
pipe_stderr=False)
try:
# wait for the process to finish
while process.status == RUNNING:
time.sleep(1)
# the pipes should be unexistant
self.assertTrue(process.stdout is None)
self.assertTrue(process.stderr is None)
finally:
process.stop()
# 3. streams & pipes open
process = Process('test', cmd, args=args)
try:
# wait for the process to finish
while process.status == RUNNING:
time.sleep(1)
# the pipes should be unexistant
self.assertEqual(len(process.stdout.read()), 2890)
self.assertEqual(len(process.stderr.read()), 2890)
finally:
process.stop()