本文整理汇总了Python中distributed.core.Server.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Server.stop方法的具体用法?Python Server.stop怎么用?Python Server.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distributed.core.Server
的用法示例。
在下文中一共展示了Server.stop方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: f
# 需要导入模块: from distributed.core import Server [as 别名]
# 或者: from distributed.core.Server import stop [as 别名]
def f():
server = Server({'ping': pingpong})
with pytest.raises(ValueError):
server.port
server.listen(8881)
assert server.port == 8881
assert server.address == ('tcp://%s:8881' % get_ip())
for addr in ('127.0.0.1:8881', 'tcp://127.0.0.1:8881', server.address):
comm = yield connect(addr)
n = yield comm.write({'op': 'ping'})
assert isinstance(n, int)
assert 4 <= n <= 1000
response = yield comm.read()
assert response == b'pong'
yield comm.write({'op': 'ping', 'close': True})
response = yield comm.read()
assert response == b'pong'
yield comm.close()
server.stop()
示例2: check_rpc_message_lifetime
# 需要导入模块: from distributed.core import Server [as 别名]
# 或者: from distributed.core.Server import stop [as 别名]
def check_rpc_message_lifetime(*listen_args):
# Issue #956: rpc arguments and result shouldn't be kept alive longer
# than necessary
server = Server({'echo': echo_serialize})
server.listen(*listen_args)
# Sanity check
obj = CountedObject()
assert CountedObject.n_instances == 1
del obj
assert CountedObject.n_instances == 0
with rpc(server.address) as remote:
obj = CountedObject()
res = yield remote.echo(x=to_serialize(obj))
assert isinstance(res['result'], CountedObject)
# Make sure resource cleanup code in coroutines runs
yield gen.sleep(0.05)
w1 = weakref.ref(obj)
w2 = weakref.ref(res['result'])
del obj, res
assert w1() is None
assert w2() is None
# If additional instances were created, they were deleted as well
assert CountedObject.n_instances == 0
server.stop()
示例3: f
# 需要导入模块: from distributed.core import Server [as 别名]
# 或者: from distributed.core.Server import stop [as 别名]
def f():
server = Server({'ping': pingpong})
server.listen(8887)
yield [g() for i in range(10)]
server.stop()
remote.close_streams()
assert all(stream.closed() for stream in remote.streams)
示例4: f
# 需要导入模块: from distributed.core import Server [as 别名]
# 或者: from distributed.core.Server import stop [as 别名]
def f():
server = Server({'echo': echo})
server.listen(8887)
data = b'0' * int(200e6) # slightly more than 100MB
conn = rpc(ip='127.0.0.1', port=8887)
result = yield conn.echo(x=data)
assert result == data
server.stop()
示例5: check_identity
# 需要导入模块: from distributed.core import Server [as 别名]
# 或者: from distributed.core.Server import stop [as 别名]
def check_identity(listen_arg):
server = Server({})
server.listen(listen_arg)
with rpc(server.address) as remote:
a = yield remote.identity()
b = yield remote.identity()
assert a['type'] == 'Server'
assert a['id'] == b['id']
server.stop()
示例6: f
# 需要导入模块: from distributed.core import Server [as 别名]
# 或者: from distributed.core.Server import stop [as 别名]
def f():
server = Server({"ping": pingpong})
server.listen(8887)
remote = rpc(ip="127.0.0.1", port=8887)
response = yield remote.ping()
assert response == b"pong"
response = yield remote.ping(close=True)
assert response == b"pong"
server.stop()
示例7: f
# 需要导入模块: from distributed.core import Server [as 别名]
# 或者: from distributed.core.Server import stop [as 别名]
def f():
server = Server({'ping': pingpong})
server.listen(8887)
with rpc(ip='127.0.0.1', port=8887) as remote:
response = yield remote.ping()
assert response == b'pong'
response = yield remote.ping(close=True)
assert response == b'pong'
assert not remote.streams
assert remote.status == 'closed'
server.stop()
示例8: check_rpc_with_many_connections
# 需要导入模块: from distributed.core import Server [as 别名]
# 或者: from distributed.core.Server import stop [as 别名]
def check_rpc_with_many_connections(listen_arg):
@gen.coroutine
def g():
for i in range(10):
yield remote.ping()
server = Server({'ping': pingpong})
server.listen(listen_arg)
remote = rpc(server.address)
yield [g() for i in range(10)]
server.stop()
remote.close_comms()
assert all(comm.closed() for comm in remote.comms)
示例9: check_large_packets
# 需要导入模块: from distributed.core import Server [as 别名]
# 或者: from distributed.core.Server import stop [as 别名]
def check_large_packets(listen_arg):
""" tornado has a 100MB cap by default """
server = Server({'echo': echo})
server.listen(listen_arg)
data = b'0' * int(200e6) # slightly more than 100MB
conn = rpc(server.address)
result = yield conn.echo(x=data)
assert result == data
d = {'x': data}
result = yield conn.echo(x=d)
assert result == d
conn.close_comms()
server.stop()
示例10: test_send_recv_args
# 需要导入模块: from distributed.core import Server [as 别名]
# 或者: from distributed.core.Server import stop [as 别名]
def test_send_recv_args():
server = Server({'echo': echo})
server.listen(0)
comm = yield connect(server.address)
result = yield send_recv(comm, op='echo', x=b'1')
assert result == b'1'
assert not comm.closed()
result = yield send_recv(comm, op='echo', x=b'2', reply=False)
assert result is None
assert not comm.closed()
result = yield send_recv(comm, op='echo', x=b'3', close=True)
assert result == b'3'
assert comm.closed()
server.stop()
示例11: test_send_recv_args
# 需要导入模块: from distributed.core import Server [as 别名]
# 或者: from distributed.core.Server import stop [as 别名]
def test_send_recv_args():
server = Server({'echo': echo})
server.listen(0)
result = yield send_recv(arg=('127.0.0.1', server.port), op='echo', x=b'1')
assert result == b'1'
result = yield send_recv(addr=('127.0.0.1:%d' % server.port).encode(),
op='echo', x=b'1')
assert result == b'1'
result = yield send_recv(ip=b'127.0.0.1', port=server.port, op='echo',
x=b'1')
assert result == b'1'
result = yield send_recv(ip=b'127.0.0.1', port=server.port, op='echo',
x=b'1', reply=False)
assert result == None
server.stop()
示例12: test_ports
# 需要导入模块: from distributed.core import Server [as 别名]
# 或者: from distributed.core.Server import stop [as 别名]
def test_ports(loop):
port = 9876
server = Server({}, io_loop=loop)
server.listen(port)
try:
assert server.port == port
with pytest.raises((OSError, socket.error)):
server2 = Server({}, io_loop=loop)
server2.listen(port)
finally:
server.stop()
try:
server3 = Server({}, io_loop=loop)
server3.listen(0)
assert isinstance(server3.port, int)
assert server3.port > 1024
finally:
server3.stop()
示例13: check_rpc
# 需要导入模块: from distributed.core import Server [as 别名]
# 或者: from distributed.core.Server import stop [as 别名]
def check_rpc(listen_addr, rpc_addr=None, listen_args=None, connection_args=None):
server = Server({'ping': pingpong})
server.listen(listen_addr, listen_args=listen_args)
if rpc_addr is None:
rpc_addr = server.address
with rpc(rpc_addr, connection_args=connection_args) as remote:
response = yield remote.ping()
assert response == b'pong'
assert remote.comms
response = yield remote.ping(close=True)
assert response == b'pong'
response = yield remote.ping()
assert response == b'pong'
assert not remote.comms
assert remote.status == 'closed'
server.stop()