repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
uber/tchannel-python | tchannel/tornado/peer.py | Peer.incoming_connections | def incoming_connections(self):
"""Returns a list of all incoming connections for this peer."""
# Incoming connections are on the left.
return list(
takewhile(lambda c: c.direction == INCOMING, self.connections)
) | python | def incoming_connections(self):
"""Returns a list of all incoming connections for this peer."""
# Incoming connections are on the left.
return list(
takewhile(lambda c: c.direction == INCOMING, self.connections)
) | [
"def",
"incoming_connections",
"(",
"self",
")",
":",
"return",
"list",
"(",
"takewhile",
"(",
"lambda",
"c",
":",
"c",
".",
"direction",
"==",
"INCOMING",
",",
"self",
".",
"connections",
")",
")"
] | Returns a list of all incoming connections for this peer. | [
"Returns",
"a",
"list",
"of",
"all",
"incoming",
"connections",
"for",
"this",
"peer",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/peer.py#L224-L230 | train |
uber/tchannel-python | tchannel/tornado/peer.py | PeerClientOperation._get_peer_connection | def _get_peer_connection(self, blacklist=None):
"""Find a peer and connect to it.
Returns a ``(peer, connection)`` tuple.
Raises ``NoAvailablePeerError`` if no healthy peers are found.
:param blacklist:
If given, a set of hostports for peers that we must not try.
"... | python | def _get_peer_connection(self, blacklist=None):
"""Find a peer and connect to it.
Returns a ``(peer, connection)`` tuple.
Raises ``NoAvailablePeerError`` if no healthy peers are found.
:param blacklist:
If given, a set of hostports for peers that we must not try.
"... | [
"def",
"_get_peer_connection",
"(",
"self",
",",
"blacklist",
"=",
"None",
")",
":",
"blacklist",
"=",
"blacklist",
"or",
"set",
"(",
")",
"peer",
"=",
"None",
"connection",
"=",
"None",
"while",
"connection",
"is",
"None",
":",
"peer",
"=",
"self",
".",... | Find a peer and connect to it.
Returns a ``(peer, connection)`` tuple.
Raises ``NoAvailablePeerError`` if no healthy peers are found.
:param blacklist:
If given, a set of hostports for peers that we must not try. | [
"Find",
"a",
"peer",
"and",
"connect",
"to",
"it",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/peer.py#L314-L349 | train |
uber/tchannel-python | tchannel/tornado/peer.py | PeerClientOperation.send | def send(
self, arg1, arg2, arg3,
headers=None,
retry_limit=None,
ttl=None,
):
"""Make a request to the Peer.
:param arg1:
String or Stream containing the contents of arg1. If None, an empty
stream is used.
:param arg2:
Str... | python | def send(
self, arg1, arg2, arg3,
headers=None,
retry_limit=None,
ttl=None,
):
"""Make a request to the Peer.
:param arg1:
String or Stream containing the contents of arg1. If None, an empty
stream is used.
:param arg2:
Str... | [
"def",
"send",
"(",
"self",
",",
"arg1",
",",
"arg2",
",",
"arg3",
",",
"headers",
"=",
"None",
",",
"retry_limit",
"=",
"None",
",",
"ttl",
"=",
"None",
",",
")",
":",
"peer",
",",
"connection",
"=",
"yield",
"self",
".",
"_get_peer_connection",
"("... | Make a request to the Peer.
:param arg1:
String or Stream containing the contents of arg1. If None, an empty
stream is used.
:param arg2:
String or Stream containing the contents of arg2. If None, an empty
stream is used.
:param arg3:
... | [
"Make",
"a",
"request",
"to",
"the",
"Peer",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/peer.py#L352-L442 | train |
uber/tchannel-python | tchannel/tornado/peer.py | PeerGroup.clear | def clear(self):
"""Reset this PeerGroup.
This closes all connections to all known peers and forgets about
these peers.
:returns:
A Future that resolves with a value of None when the operation
has finished
"""
try:
for peer in self._p... | python | def clear(self):
"""Reset this PeerGroup.
This closes all connections to all known peers and forgets about
these peers.
:returns:
A Future that resolves with a value of None when the operation
has finished
"""
try:
for peer in self._p... | [
"def",
"clear",
"(",
"self",
")",
":",
"try",
":",
"for",
"peer",
"in",
"self",
".",
"_peers",
".",
"values",
"(",
")",
":",
"peer",
".",
"close",
"(",
")",
"finally",
":",
"self",
".",
"_peers",
"=",
"{",
"}",
"self",
".",
"_resetting",
"=",
"... | Reset this PeerGroup.
This closes all connections to all known peers and forgets about
these peers.
:returns:
A Future that resolves with a value of None when the operation
has finished | [
"Reset",
"this",
"PeerGroup",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/peer.py#L592-L607 | train |
uber/tchannel-python | tchannel/tornado/peer.py | PeerGroup.remove | def remove(self, hostport):
"""Delete the Peer for the given host port.
Does nothing if a matching Peer does not exist.
:returns: The removed Peer
"""
assert hostport, "hostport is required"
peer = self._peers.pop(hostport, None)
peer_in_heap = peer and peer.ind... | python | def remove(self, hostport):
"""Delete the Peer for the given host port.
Does nothing if a matching Peer does not exist.
:returns: The removed Peer
"""
assert hostport, "hostport is required"
peer = self._peers.pop(hostport, None)
peer_in_heap = peer and peer.ind... | [
"def",
"remove",
"(",
"self",
",",
"hostport",
")",
":",
"assert",
"hostport",
",",
"\"hostport is required\"",
"peer",
"=",
"self",
".",
"_peers",
".",
"pop",
"(",
"hostport",
",",
"None",
")",
"peer_in_heap",
"=",
"peer",
"and",
"peer",
".",
"index",
"... | Delete the Peer for the given host port.
Does nothing if a matching Peer does not exist.
:returns: The removed Peer | [
"Delete",
"the",
"Peer",
"for",
"the",
"given",
"host",
"port",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/peer.py#L617-L629 | train |
uber/tchannel-python | tchannel/tornado/peer.py | PeerGroup.get | def get(self, hostport):
"""Get a Peer for the given destination.
A new Peer is added to the peer heap and returned if one does
not already exist for the given host-port. Otherwise, the
existing Peer is returned.
"""
assert hostport, "hostport is required"
assert... | python | def get(self, hostport):
"""Get a Peer for the given destination.
A new Peer is added to the peer heap and returned if one does
not already exist for the given host-port. Otherwise, the
existing Peer is returned.
"""
assert hostport, "hostport is required"
assert... | [
"def",
"get",
"(",
"self",
",",
"hostport",
")",
":",
"assert",
"hostport",
",",
"\"hostport is required\"",
"assert",
"isinstance",
"(",
"hostport",
",",
"basestring",
")",
",",
"\"hostport must be a string\"",
"if",
"hostport",
"not",
"in",
"self",
".",
"_peer... | Get a Peer for the given destination.
A new Peer is added to the peer heap and returned if one does
not already exist for the given host-port. Otherwise, the
existing Peer is returned. | [
"Get",
"a",
"Peer",
"for",
"the",
"given",
"destination",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/peer.py#L631-L644 | train |
uber/tchannel-python | tchannel/tornado/peer.py | PeerGroup._add | def _add(self, hostport):
"""Creates a peer from the hostport and adds it to the peer heap"""
peer = self.peer_class(
tchannel=self.tchannel,
hostport=hostport,
on_conn_change=self._update_heap,
)
peer.rank = self.rank_calculator.get_rank(peer)
... | python | def _add(self, hostport):
"""Creates a peer from the hostport and adds it to the peer heap"""
peer = self.peer_class(
tchannel=self.tchannel,
hostport=hostport,
on_conn_change=self._update_heap,
)
peer.rank = self.rank_calculator.get_rank(peer)
... | [
"def",
"_add",
"(",
"self",
",",
"hostport",
")",
":",
"peer",
"=",
"self",
".",
"peer_class",
"(",
"tchannel",
"=",
"self",
".",
"tchannel",
",",
"hostport",
"=",
"hostport",
",",
"on_conn_change",
"=",
"self",
".",
"_update_heap",
",",
")",
"peer",
"... | Creates a peer from the hostport and adds it to the peer heap | [
"Creates",
"a",
"peer",
"from",
"the",
"hostport",
"and",
"adds",
"it",
"to",
"the",
"peer",
"heap"
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/peer.py#L646-L656 | train |
uber/tchannel-python | tchannel/tornado/peer.py | PeerGroup._update_heap | def _update_heap(self, peer):
"""Recalculate the peer's rank and update itself in the peer heap."""
rank = self.rank_calculator.get_rank(peer)
if rank == peer.rank:
return
peer.rank = rank
self.peer_heap.update_peer(peer) | python | def _update_heap(self, peer):
"""Recalculate the peer's rank and update itself in the peer heap."""
rank = self.rank_calculator.get_rank(peer)
if rank == peer.rank:
return
peer.rank = rank
self.peer_heap.update_peer(peer) | [
"def",
"_update_heap",
"(",
"self",
",",
"peer",
")",
":",
"rank",
"=",
"self",
".",
"rank_calculator",
".",
"get_rank",
"(",
"peer",
")",
"if",
"rank",
"==",
"peer",
".",
"rank",
":",
"return",
"peer",
".",
"rank",
"=",
"rank",
"self",
".",
"peer_he... | Recalculate the peer's rank and update itself in the peer heap. | [
"Recalculate",
"the",
"peer",
"s",
"rank",
"and",
"update",
"itself",
"in",
"the",
"peer",
"heap",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/peer.py#L658-L665 | train |
uber/tchannel-python | tchannel/tornado/peer.py | PeerGroup._get_isolated | def _get_isolated(self, hostport):
"""Get a Peer for the given destination for a request.
A new Peer is added and returned if one does not already exist for the
given host-port. Otherwise, the existing Peer is returned.
**NOTE** new peers will not be added to the peer heap.
"""... | python | def _get_isolated(self, hostport):
"""Get a Peer for the given destination for a request.
A new Peer is added and returned if one does not already exist for the
given host-port. Otherwise, the existing Peer is returned.
**NOTE** new peers will not be added to the peer heap.
"""... | [
"def",
"_get_isolated",
"(",
"self",
",",
"hostport",
")",
":",
"assert",
"hostport",
",",
"\"hostport is required\"",
"if",
"hostport",
"not",
"in",
"self",
".",
"_peers",
":",
"peer",
"=",
"self",
".",
"peer_class",
"(",
"tchannel",
"=",
"self",
".",
"tc... | Get a Peer for the given destination for a request.
A new Peer is added and returned if one does not already exist for the
given host-port. Otherwise, the existing Peer is returned.
**NOTE** new peers will not be added to the peer heap. | [
"Get",
"a",
"Peer",
"for",
"the",
"given",
"destination",
"for",
"a",
"request",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/peer.py#L667-L685 | train |
uber/tchannel-python | tchannel/tornado/peer.py | PeerGroup.request | def request(self, service, hostport=None, **kwargs):
"""Initiate a new request through this PeerGroup.
:param hostport:
If specified, requests will be sent to the specific host.
Otherwise, a known peer will be picked at random.
:param service:
Name of the ser... | python | def request(self, service, hostport=None, **kwargs):
"""Initiate a new request through this PeerGroup.
:param hostport:
If specified, requests will be sent to the specific host.
Otherwise, a known peer will be picked at random.
:param service:
Name of the ser... | [
"def",
"request",
"(",
"self",
",",
"service",
",",
"hostport",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"return",
"PeerClientOperation",
"(",
"peer_group",
"=",
"self",
",",
"service",
"=",
"service",
",",
"hostport",
"=",
"hostport",
",",
"**",
"kwa... | Initiate a new request through this PeerGroup.
:param hostport:
If specified, requests will be sent to the specific host.
Otherwise, a known peer will be picked at random.
:param service:
Name of the service being called. Defaults to an empty string. | [
"Initiate",
"a",
"new",
"request",
"through",
"this",
"PeerGroup",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/peer.py#L697-L710 | train |
uber/tchannel-python | tchannel/tornado/peer.py | PeerGroup.choose | def choose(self, hostport=None, blacklist=None):
"""Choose a Peer that matches the given criteria.
:param hostport:
Specifies that the returned Peer must be for the given host-port.
Without this, all peers managed by this PeerGroup are
candidates.
:param blac... | python | def choose(self, hostport=None, blacklist=None):
"""Choose a Peer that matches the given criteria.
:param hostport:
Specifies that the returned Peer must be for the given host-port.
Without this, all peers managed by this PeerGroup are
candidates.
:param blac... | [
"def",
"choose",
"(",
"self",
",",
"hostport",
"=",
"None",
",",
"blacklist",
"=",
"None",
")",
":",
"blacklist",
"=",
"blacklist",
"or",
"set",
"(",
")",
"if",
"hostport",
":",
"return",
"self",
".",
"_get_isolated",
"(",
"hostport",
")",
"return",
"s... | Choose a Peer that matches the given criteria.
:param hostport:
Specifies that the returned Peer must be for the given host-port.
Without this, all peers managed by this PeerGroup are
candidates.
:param blacklist:
Peers on the blacklist won't be chosen.
... | [
"Choose",
"a",
"Peer",
"that",
"matches",
"the",
"given",
"criteria",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/peer.py#L712-L732 | train |
uber/tchannel-python | tchannel/_future.py | fail_to | def fail_to(future):
"""A decorator for function callbacks to catch uncaught non-async
exceptions and forward them to the given future.
The primary use for this is to catch exceptions in async callbacks and
propagate them to futures. For example, consider,
.. code-block:: python
answer = ... | python | def fail_to(future):
"""A decorator for function callbacks to catch uncaught non-async
exceptions and forward them to the given future.
The primary use for this is to catch exceptions in async callbacks and
propagate them to futures. For example, consider,
.. code-block:: python
answer = ... | [
"def",
"fail_to",
"(",
"future",
")",
":",
"assert",
"is_future",
"(",
"future",
")",
",",
"'you forgot to pass a future'",
"def",
"decorator",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"new_f",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",... | A decorator for function callbacks to catch uncaught non-async
exceptions and forward them to the given future.
The primary use for this is to catch exceptions in async callbacks and
propagate them to futures. For example, consider,
.. code-block:: python
answer = Future()
def on_don... | [
"A",
"decorator",
"for",
"function",
"callbacks",
"to",
"catch",
"uncaught",
"non",
"-",
"async",
"exceptions",
"and",
"forward",
"them",
"to",
"the",
"given",
"future",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/_future.py#L31-L78 | train |
uber/tchannel-python | tchannel/tornado/util.py | get_arg | def get_arg(context, index):
"""get value from arg stream in async way"""
if index < len(context.argstreams):
arg = ""
chunk = yield context.argstreams[index].read()
while chunk:
arg += chunk
chunk = yield context.argstreams[index].read()
raise tornado.ge... | python | def get_arg(context, index):
"""get value from arg stream in async way"""
if index < len(context.argstreams):
arg = ""
chunk = yield context.argstreams[index].read()
while chunk:
arg += chunk
chunk = yield context.argstreams[index].read()
raise tornado.ge... | [
"def",
"get_arg",
"(",
"context",
",",
"index",
")",
":",
"if",
"index",
"<",
"len",
"(",
"context",
".",
"argstreams",
")",
":",
"arg",
"=",
"\"\"",
"chunk",
"=",
"yield",
"context",
".",
"argstreams",
"[",
"index",
"]",
".",
"read",
"(",
")",
"wh... | get value from arg stream in async way | [
"get",
"value",
"from",
"arg",
"stream",
"in",
"async",
"way"
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/util.py#L30-L41 | train |
uber/tchannel-python | tchannel/_queue.py | Queue.put | def put(self, value):
"""Puts an item into the queue.
Returns a Future that resolves to None once the value has been
accepted by the queue.
"""
io_loop = IOLoop.current()
new_hole = Future()
new_put = Future()
new_put.set_result(new_hole)
with s... | python | def put(self, value):
"""Puts an item into the queue.
Returns a Future that resolves to None once the value has been
accepted by the queue.
"""
io_loop = IOLoop.current()
new_hole = Future()
new_put = Future()
new_put.set_result(new_hole)
with s... | [
"def",
"put",
"(",
"self",
",",
"value",
")",
":",
"io_loop",
"=",
"IOLoop",
".",
"current",
"(",
")",
"new_hole",
"=",
"Future",
"(",
")",
"new_put",
"=",
"Future",
"(",
")",
"new_put",
".",
"set_result",
"(",
"new_hole",
")",
"with",
"self",
".",
... | Puts an item into the queue.
Returns a Future that resolves to None once the value has been
accepted by the queue. | [
"Puts",
"an",
"item",
"into",
"the",
"queue",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/_queue.py#L107-L133 | train |
uber/tchannel-python | tchannel/_queue.py | Queue.get_nowait | def get_nowait(self):
"""Returns a value from the queue without waiting.
Raises ``QueueEmpty`` if no values are available right now.
"""
new_get = Future()
with self._lock:
if not self._get.done():
raise QueueEmpty
get, self._get = self._... | python | def get_nowait(self):
"""Returns a value from the queue without waiting.
Raises ``QueueEmpty`` if no values are available right now.
"""
new_get = Future()
with self._lock:
if not self._get.done():
raise QueueEmpty
get, self._get = self._... | [
"def",
"get_nowait",
"(",
"self",
")",
":",
"new_get",
"=",
"Future",
"(",
")",
"with",
"self",
".",
"_lock",
":",
"if",
"not",
"self",
".",
"_get",
".",
"done",
"(",
")",
":",
"raise",
"QueueEmpty",
"get",
",",
"self",
".",
"_get",
"=",
"self",
... | Returns a value from the queue without waiting.
Raises ``QueueEmpty`` if no values are available right now. | [
"Returns",
"a",
"value",
"from",
"the",
"queue",
"without",
"waiting",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/_queue.py#L135-L157 | train |
uber/tchannel-python | tchannel/_queue.py | Queue.get | def get(self):
"""Gets the next item from the queue.
Returns a Future that resolves to the next item once it is available.
"""
io_loop = IOLoop.current()
new_get = Future()
with self._lock:
get, self._get = self._get, new_get
answer = Future()
... | python | def get(self):
"""Gets the next item from the queue.
Returns a Future that resolves to the next item once it is available.
"""
io_loop = IOLoop.current()
new_get = Future()
with self._lock:
get, self._get = self._get, new_get
answer = Future()
... | [
"def",
"get",
"(",
"self",
")",
":",
"io_loop",
"=",
"IOLoop",
".",
"current",
"(",
")",
"new_get",
"=",
"Future",
"(",
")",
"with",
"self",
".",
"_lock",
":",
"get",
",",
"self",
".",
"_get",
"=",
"self",
".",
"_get",
",",
"new_get",
"answer",
"... | Gets the next item from the queue.
Returns a Future that resolves to the next item once it is available. | [
"Gets",
"the",
"next",
"item",
"from",
"the",
"queue",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/_queue.py#L159-L190 | train |
uber/tchannel-python | tchannel/messages/call_continue.py | CallContinueMessage.fragment | def fragment(self, space_left, fragment_msg):
"""Streaming Message got fragmented based on
payload size. All the data within space_left
will be kept. All the rest will be shifted to
next fragment message.
:param space_left:
space left for current frame
:param... | python | def fragment(self, space_left, fragment_msg):
"""Streaming Message got fragmented based on
payload size. All the data within space_left
will be kept. All the rest will be shifted to
next fragment message.
:param space_left:
space left for current frame
:param... | [
"def",
"fragment",
"(",
"self",
",",
"space_left",
",",
"fragment_msg",
")",
":",
"new_args",
"=",
"[",
"]",
"key_length",
"=",
"2",
"for",
"i",
",",
"arg",
"in",
"enumerate",
"(",
"self",
".",
"args",
")",
":",
"if",
"space_left",
">=",
"key_length",
... | Streaming Message got fragmented based on
payload size. All the data within space_left
will be kept. All the rest will be shifted to
next fragment message.
:param space_left:
space left for current frame
:param fragment_msg:
the type is either CallRequest... | [
"Streaming",
"Message",
"got",
"fragmented",
"based",
"on",
"payload",
"size",
".",
"All",
"the",
"data",
"within",
"space_left",
"will",
"be",
"kept",
".",
"All",
"the",
"rest",
"will",
"be",
"shifted",
"to",
"next",
"fragment",
"message",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/messages/call_continue.py#L55-L101 | train |
uber/tchannel-python | tchannel/response.py | response_from_mixed | def response_from_mixed(mixed):
"""Create Response from mixed input."""
# if none then give empty Response
if mixed is None:
return Response()
# if not Response, then treat like body
if not isinstance(mixed, Response):
return Response(mixed)
# it's already a Response
retur... | python | def response_from_mixed(mixed):
"""Create Response from mixed input."""
# if none then give empty Response
if mixed is None:
return Response()
# if not Response, then treat like body
if not isinstance(mixed, Response):
return Response(mixed)
# it's already a Response
retur... | [
"def",
"response_from_mixed",
"(",
"mixed",
")",
":",
"if",
"mixed",
"is",
"None",
":",
"return",
"Response",
"(",
")",
"if",
"not",
"isinstance",
"(",
"mixed",
",",
"Response",
")",
":",
"return",
"Response",
"(",
"mixed",
")",
"return",
"mixed"
] | Create Response from mixed input. | [
"Create",
"Response",
"from",
"mixed",
"input",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/response.py#L104-L116 | train |
uber/tchannel-python | tchannel/event.py | EventEmitter.register_hook | def register_hook(self, hook, event_type=None):
"""
If ``event_type`` is provided, then ``hook`` will be called whenever
that event is fired.
If no ``event_type`` is specifid, but ``hook`` implements any methods
with names matching an event hook, then those will be registered wi... | python | def register_hook(self, hook, event_type=None):
"""
If ``event_type`` is provided, then ``hook`` will be called whenever
that event is fired.
If no ``event_type`` is specifid, but ``hook`` implements any methods
with names matching an event hook, then those will be registered wi... | [
"def",
"register_hook",
"(",
"self",
",",
"hook",
",",
"event_type",
"=",
"None",
")",
":",
"if",
"event_type",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"event_type",
")",
"is",
"int",
",",
"\"register hooks with int values\"",
"return",
"self",
".",... | If ``event_type`` is provided, then ``hook`` will be called whenever
that event is fired.
If no ``event_type`` is specifid, but ``hook`` implements any methods
with names matching an event hook, then those will be registered with
their corresponding events. This allows for more stateful... | [
"If",
"event_type",
"is",
"provided",
"then",
"hook",
"will",
"be",
"called",
"whenever",
"that",
"event",
"is",
"fired",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/event.py#L133-L151 | train |
uber/tchannel-python | tchannel/container/heap.py | init | def init(h):
"""Initialize existing object into the heap."""
# heapify
n = h.size()
for i in six.moves.range(int(math.floor(n/2)) - 1, -1, -1):
down(h, i, n) | python | def init(h):
"""Initialize existing object into the heap."""
# heapify
n = h.size()
for i in six.moves.range(int(math.floor(n/2)) - 1, -1, -1):
down(h, i, n) | [
"def",
"init",
"(",
"h",
")",
":",
"n",
"=",
"h",
".",
"size",
"(",
")",
"for",
"i",
"in",
"six",
".",
"moves",
".",
"range",
"(",
"int",
"(",
"math",
".",
"floor",
"(",
"n",
"/",
"2",
")",
")",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
... | Initialize existing object into the heap. | [
"Initialize",
"existing",
"object",
"into",
"the",
"heap",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/container/heap.py#L74-L79 | train |
uber/tchannel-python | tchannel/container/heap.py | push | def push(h, x):
"""Push a new value into heap."""
h.push(x)
up(h, h.size()-1) | python | def push(h, x):
"""Push a new value into heap."""
h.push(x)
up(h, h.size()-1) | [
"def",
"push",
"(",
"h",
",",
"x",
")",
":",
"h",
".",
"push",
"(",
"x",
")",
"up",
"(",
"h",
",",
"h",
".",
"size",
"(",
")",
"-",
"1",
")"
] | Push a new value into heap. | [
"Push",
"a",
"new",
"value",
"into",
"heap",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/container/heap.py#L82-L85 | train |
uber/tchannel-python | tchannel/container/heap.py | pop | def pop(h):
"""Pop the heap value from the heap."""
n = h.size() - 1
h.swap(0, n)
down(h, 0, n)
return h.pop() | python | def pop(h):
"""Pop the heap value from the heap."""
n = h.size() - 1
h.swap(0, n)
down(h, 0, n)
return h.pop() | [
"def",
"pop",
"(",
"h",
")",
":",
"n",
"=",
"h",
".",
"size",
"(",
")",
"-",
"1",
"h",
".",
"swap",
"(",
"0",
",",
"n",
")",
"down",
"(",
"h",
",",
"0",
",",
"n",
")",
"return",
"h",
".",
"pop",
"(",
")"
] | Pop the heap value from the heap. | [
"Pop",
"the",
"heap",
"value",
"from",
"the",
"heap",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/container/heap.py#L88-L93 | train |
uber/tchannel-python | tchannel/container/heap.py | remove | def remove(h, i):
"""Remove the item at position i of the heap."""
n = h.size() - 1
if n != i:
h.swap(i, n)
down(h, i, n)
up(h, i)
return h.pop() | python | def remove(h, i):
"""Remove the item at position i of the heap."""
n = h.size() - 1
if n != i:
h.swap(i, n)
down(h, i, n)
up(h, i)
return h.pop() | [
"def",
"remove",
"(",
"h",
",",
"i",
")",
":",
"n",
"=",
"h",
".",
"size",
"(",
")",
"-",
"1",
"if",
"n",
"!=",
"i",
":",
"h",
".",
"swap",
"(",
"i",
",",
"n",
")",
"down",
"(",
"h",
",",
"i",
",",
"n",
")",
"up",
"(",
"h",
",",
"i"... | Remove the item at position i of the heap. | [
"Remove",
"the",
"item",
"at",
"position",
"i",
"of",
"the",
"heap",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/container/heap.py#L96-L104 | train |
uber/tchannel-python | tchannel/container/heap.py | fix | def fix(h, i):
"""Rearrange the heap after the item at position i got updated."""
down(h, i, h.size())
up(h, i) | python | def fix(h, i):
"""Rearrange the heap after the item at position i got updated."""
down(h, i, h.size())
up(h, i) | [
"def",
"fix",
"(",
"h",
",",
"i",
")",
":",
"down",
"(",
"h",
",",
"i",
",",
"h",
".",
"size",
"(",
")",
")",
"up",
"(",
"h",
",",
"i",
")"
] | Rearrange the heap after the item at position i got updated. | [
"Rearrange",
"the",
"heap",
"after",
"the",
"item",
"at",
"position",
"i",
"got",
"updated",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/container/heap.py#L107-L110 | train |
uber/tchannel-python | tchannel/container/heap.py | smallest | def smallest(heap, predicate):
"""Finds the index of the smallest item in the heap that matches the given
predicate.
:param heap:
Heap on which this search is being performed.
:param predicate:
Function that accepts an item from the heap and returns true or false.
:returns:
... | python | def smallest(heap, predicate):
"""Finds the index of the smallest item in the heap that matches the given
predicate.
:param heap:
Heap on which this search is being performed.
:param predicate:
Function that accepts an item from the heap and returns true or false.
:returns:
... | [
"def",
"smallest",
"(",
"heap",
",",
"predicate",
")",
":",
"n",
"=",
"heap",
".",
"size",
"(",
")",
"items",
"=",
"deque",
"(",
"[",
"0",
"]",
")",
"while",
"items",
":",
"current",
"=",
"items",
".",
"popleft",
"(",
")",
"if",
"current",
">=",
... | Finds the index of the smallest item in the heap that matches the given
predicate.
:param heap:
Heap on which this search is being performed.
:param predicate:
Function that accepts an item from the heap and returns true or false.
:returns:
Index of the first item for which ``pr... | [
"Finds",
"the",
"index",
"of",
"the",
"smallest",
"item",
"in",
"the",
"heap",
"that",
"matches",
"the",
"given",
"predicate",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/container/heap.py#L141-L179 | train |
uber/tchannel-python | tchannel/tracing.py | ServerTracer.start_basic_span | def start_basic_span(self, request):
"""
Start tracing span from the protocol's `tracing` fields.
This will only work if the `tracer` supports Zipkin-style span context.
:param request: inbound request
:type request: tchannel.tornado.request.Request
"""
# noinspe... | python | def start_basic_span(self, request):
"""
Start tracing span from the protocol's `tracing` fields.
This will only work if the `tracer` supports Zipkin-style span context.
:param request: inbound request
:type request: tchannel.tornado.request.Request
"""
# noinspe... | [
"def",
"start_basic_span",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"if",
"request",
".",
"tracing",
".",
"trace_id",
":",
"context",
"=",
"self",
".",
"tracer",
".",
"extract",
"(",
"format",
"=",
"ZIPKIN_SPAN_FORMAT",
",",
"carrier",
"=",
"re... | Start tracing span from the protocol's `tracing` fields.
This will only work if the `tracer` supports Zipkin-style span context.
:param request: inbound request
:type request: tchannel.tornado.request.Request | [
"Start",
"tracing",
"span",
"from",
"the",
"protocol",
"s",
"tracing",
"fields",
".",
"This",
"will",
"only",
"work",
"if",
"the",
"tracer",
"supports",
"Zipkin",
"-",
"style",
"span",
"context",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tracing.py#L111-L135 | train |
uber/tchannel-python | tchannel/tracing.py | ServerTracer.start_span | def start_span(self, request, headers, peer_host, peer_port):
"""
Start a new server-side span. If the span has already been started
by `start_basic_span`, this method only adds baggage from the headers.
:param request: inbound tchannel.tornado.request.Request
:param headers: di... | python | def start_span(self, request, headers, peer_host, peer_port):
"""
Start a new server-side span. If the span has already been started
by `start_basic_span`, this method only adds baggage from the headers.
:param request: inbound tchannel.tornado.request.Request
:param headers: di... | [
"def",
"start_span",
"(",
"self",
",",
"request",
",",
"headers",
",",
"peer_host",
",",
"peer_port",
")",
":",
"parent_context",
"=",
"None",
"try",
":",
"if",
"headers",
"and",
"hasattr",
"(",
"headers",
",",
"'iteritems'",
")",
":",
"tracing_headers",
"... | Start a new server-side span. If the span has already been started
by `start_basic_span`, this method only adds baggage from the headers.
:param request: inbound tchannel.tornado.request.Request
:param headers: dictionary containing parsed application headers
:return: | [
"Start",
"a",
"new",
"server",
"-",
"side",
"span",
".",
"If",
"the",
"span",
"has",
"already",
"been",
"started",
"by",
"start_basic_span",
"this",
"method",
"only",
"adds",
"baggage",
"from",
"the",
"headers",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tracing.py#L137-L180 | train |
uber/tchannel-python | tchannel/errors.py | TChannelError.from_code | def from_code(cls, code, **kw):
"""Construct a ``TChannelError`` instance from an error code.
This will return the appropriate class type for the given code.
"""
return {
TIMEOUT: TimeoutError,
CANCELED: CanceledError,
BUSY: BusyError,
DEC... | python | def from_code(cls, code, **kw):
"""Construct a ``TChannelError`` instance from an error code.
This will return the appropriate class type for the given code.
"""
return {
TIMEOUT: TimeoutError,
CANCELED: CanceledError,
BUSY: BusyError,
DEC... | [
"def",
"from_code",
"(",
"cls",
",",
"code",
",",
"**",
"kw",
")",
":",
"return",
"{",
"TIMEOUT",
":",
"TimeoutError",
",",
"CANCELED",
":",
"CanceledError",
",",
"BUSY",
":",
"BusyError",
",",
"DECLINED",
":",
"DeclinedError",
",",
"UNEXPECTED_ERROR",
":"... | Construct a ``TChannelError`` instance from an error code.
This will return the appropriate class type for the given code. | [
"Construct",
"a",
"TChannelError",
"instance",
"from",
"an",
"error",
"code",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/errors.py#L84-L99 | train |
uber/tchannel-python | tchannel/thrift/server.py | register | def register(dispatcher, service_module, handler, method=None, service=None):
"""Registers a Thrift service method with the given RequestDispatcher.
.. code-block:: python
# For,
#
# service HelloWorld { string hello(1: string name); }
import tchannel.thrift
import H... | python | def register(dispatcher, service_module, handler, method=None, service=None):
"""Registers a Thrift service method with the given RequestDispatcher.
.. code-block:: python
# For,
#
# service HelloWorld { string hello(1: string name); }
import tchannel.thrift
import H... | [
"def",
"register",
"(",
"dispatcher",
",",
"service_module",
",",
"handler",
",",
"method",
"=",
"None",
",",
"service",
"=",
"None",
")",
":",
"if",
"not",
"service",
":",
"service",
"=",
"service_module",
".",
"__name__",
".",
"rsplit",
"(",
"'.'",
","... | Registers a Thrift service method with the given RequestDispatcher.
.. code-block:: python
# For,
#
# service HelloWorld { string hello(1: string name); }
import tchannel.thrift
import HelloWorld
def hello(request, response):
name = request.args.name... | [
"Registers",
"a",
"Thrift",
"service",
"method",
"with",
"the",
"given",
"RequestDispatcher",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/thrift/server.py#L35-L100 | train |
uber/tchannel-python | tchannel/thrift/server.py | ThriftResponse.write_result | def write_result(self, result):
"""Send back the result of this call.
Only one of this and `write_exc_info` may be called.
:param result:
Return value of the call
"""
assert not self.finished, "Already sent a response"
if not self.result.thrift_spec:
... | python | def write_result(self, result):
"""Send back the result of this call.
Only one of this and `write_exc_info` may be called.
:param result:
Return value of the call
"""
assert not self.finished, "Already sent a response"
if not self.result.thrift_spec:
... | [
"def",
"write_result",
"(",
"self",
",",
"result",
")",
":",
"assert",
"not",
"self",
".",
"finished",
",",
"\"Already sent a response\"",
"if",
"not",
"self",
".",
"result",
".",
"thrift_spec",
":",
"self",
".",
"finished",
"=",
"True",
"return",
"spec",
... | Send back the result of this call.
Only one of this and `write_exc_info` may be called.
:param result:
Return value of the call | [
"Send",
"back",
"the",
"result",
"of",
"this",
"call",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/thrift/server.py#L206-L225 | train |
uber/tchannel-python | tchannel/thrift/server.py | ThriftResponse.write_exc_info | def write_exc_info(self, exc_info=None):
"""Write exception information to the response.
Only one of this and ``write_result`` may be called.
:param exc_info:
3-tuple of exception information. If omitted, the last exception
will be retrieved using ``sys.exc_info()``.
... | python | def write_exc_info(self, exc_info=None):
"""Write exception information to the response.
Only one of this and ``write_result`` may be called.
:param exc_info:
3-tuple of exception information. If omitted, the last exception
will be retrieved using ``sys.exc_info()``.
... | [
"def",
"write_exc_info",
"(",
"self",
",",
"exc_info",
"=",
"None",
")",
":",
"exc_info",
"=",
"exc_info",
"or",
"sys",
".",
"exc_info",
"(",
")",
"exc",
"=",
"exc_info",
"[",
"1",
"]",
"self",
".",
"code",
"=",
"StatusCode",
".",
"error",
"for",
"sp... | Write exception information to the response.
Only one of this and ``write_result`` may be called.
:param exc_info:
3-tuple of exception information. If omitted, the last exception
will be retrieved using ``sys.exc_info()``. | [
"Write",
"exception",
"information",
"to",
"the",
"response",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/thrift/server.py#L227-L248 | train |
uber/tchannel-python | tchannel/tchannel.py | TChannel.call | def call(
self,
scheme,
service,
arg1,
arg2=None,
arg3=None,
timeout=None,
retry_on=None,
retry_limit=None,
routing_delegate=None,
hostport=None,
shard_key=None,
tracing_span=None,
trace=None, # to trace or ... | python | def call(
self,
scheme,
service,
arg1,
arg2=None,
arg3=None,
timeout=None,
retry_on=None,
retry_limit=None,
routing_delegate=None,
hostport=None,
shard_key=None,
tracing_span=None,
trace=None, # to trace or ... | [
"def",
"call",
"(",
"self",
",",
"scheme",
",",
"service",
",",
"arg1",
",",
"arg2",
"=",
"None",
",",
"arg3",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"retry_on",
"=",
"None",
",",
"retry_limit",
"=",
"None",
",",
"routing_delegate",
"=",
"Non... | Make low-level requests to TChannel services.
**Note:** Usually you would interact with a higher-level arg scheme
like :py:class:`tchannel.schemes.JsonArgScheme` or
:py:class:`tchannel.schemes.ThriftArgScheme`. | [
"Make",
"low",
"-",
"level",
"requests",
"to",
"TChannel",
"services",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tchannel.py#L151-L235 | train |
uber/tchannel-python | tchannel/thrift/module.py | thrift_request_builder | def thrift_request_builder(service, thrift_module, hostport=None,
thrift_class_name=None):
"""Provide TChannel compatibility with Thrift-generated modules.
The service this creates is meant to be used with TChannel like so:
.. code-block:: python
from tchannel import TC... | python | def thrift_request_builder(service, thrift_module, hostport=None,
thrift_class_name=None):
"""Provide TChannel compatibility with Thrift-generated modules.
The service this creates is meant to be used with TChannel like so:
.. code-block:: python
from tchannel import TC... | [
"def",
"thrift_request_builder",
"(",
"service",
",",
"thrift_module",
",",
"hostport",
"=",
"None",
",",
"thrift_class_name",
"=",
"None",
")",
":",
"maker",
"=",
"ThriftRequestMaker",
"(",
"service",
"=",
"service",
",",
"thrift_module",
"=",
"thrift_module",
... | Provide TChannel compatibility with Thrift-generated modules.
The service this creates is meant to be used with TChannel like so:
.. code-block:: python
from tchannel import TChannel, thrift_request_builder
from some_other_service_thrift import some_other_service
tchannel = TChannel(... | [
"Provide",
"TChannel",
"compatibility",
"with",
"Thrift",
"-",
"generated",
"modules",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/thrift/module.py#L40-L104 | train |
uber/tchannel-python | tchannel/thrift/module.py | ThriftRequest.read_body | def read_body(self, body):
"""Handles the response body for this request.
If the response body includes a result, returns the result unwrapped
from the response union. If the response contains an exception, raises
that exception.
"""
result_spec = self.result_type.thrift... | python | def read_body(self, body):
"""Handles the response body for this request.
If the response body includes a result, returns the result unwrapped
from the response union. If the response contains an exception, raises
that exception.
"""
result_spec = self.result_type.thrift... | [
"def",
"read_body",
"(",
"self",
",",
"body",
")",
":",
"result_spec",
"=",
"self",
".",
"result_type",
".",
"thrift_spec",
"for",
"exc_spec",
"in",
"result_spec",
"[",
"1",
":",
"]",
":",
"exc",
"=",
"getattr",
"(",
"body",
",",
"exc_spec",
"[",
"2",
... | Handles the response body for this request.
If the response body includes a result, returns the result unwrapped
from the response union. If the response contains an exception, raises
that exception. | [
"Handles",
"the",
"response",
"body",
"for",
"this",
"request",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/thrift/module.py#L209-L240 | train |
uber/tchannel-python | tchannel/peer_strategy.py | PreferIncomingCalculator.get_rank | def get_rank(self, peer):
"""Calculate the peer rank based on connections.
If the peer has no incoming connections, it will have largest rank.
In our peer selection strategy, the largest number has least priority
in the heap.
If the peer has incoming connections, we will return... | python | def get_rank(self, peer):
"""Calculate the peer rank based on connections.
If the peer has no incoming connections, it will have largest rank.
In our peer selection strategy, the largest number has least priority
in the heap.
If the peer has incoming connections, we will return... | [
"def",
"get_rank",
"(",
"self",
",",
"peer",
")",
":",
"if",
"not",
"peer",
".",
"connections",
":",
"return",
"self",
".",
"TIERS",
"[",
"0",
"]",
"if",
"not",
"peer",
".",
"has_incoming_connections",
":",
"return",
"self",
".",
"TIERS",
"[",
"1",
"... | Calculate the peer rank based on connections.
If the peer has no incoming connections, it will have largest rank.
In our peer selection strategy, the largest number has least priority
in the heap.
If the peer has incoming connections, we will return number of outbound
pending r... | [
"Calculate",
"the",
"peer",
"rank",
"based",
"on",
"connections",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/peer_strategy.py#L41-L60 | train |
uber/tchannel-python | tchannel/singleton.py | TChannel.prepare | def prepare(cls, *args, **kwargs):
"""Set arguments to be used when instantiating a TChannel instance.
Arguments are the same as :py:meth:`tchannel.TChannel.__init__`.
"""
cls.args = args
cls.kwargs = kwargs
cls.prepared = True | python | def prepare(cls, *args, **kwargs):
"""Set arguments to be used when instantiating a TChannel instance.
Arguments are the same as :py:meth:`tchannel.TChannel.__init__`.
"""
cls.args = args
cls.kwargs = kwargs
cls.prepared = True | [
"def",
"prepare",
"(",
"cls",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"cls",
".",
"args",
"=",
"args",
"cls",
".",
"kwargs",
"=",
"kwargs",
"cls",
".",
"prepared",
"=",
"True"
] | Set arguments to be used when instantiating a TChannel instance.
Arguments are the same as :py:meth:`tchannel.TChannel.__init__`. | [
"Set",
"arguments",
"to",
"be",
"used",
"when",
"instantiating",
"a",
"TChannel",
"instance",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/singleton.py#L44-L51 | train |
uber/tchannel-python | tchannel/singleton.py | TChannel.reset | def reset(cls, *args, **kwargs):
"""Undo call to prepare, useful for testing."""
cls.local.tchannel = None
cls.args = None
cls.kwargs = None
cls.prepared = False | python | def reset(cls, *args, **kwargs):
"""Undo call to prepare, useful for testing."""
cls.local.tchannel = None
cls.args = None
cls.kwargs = None
cls.prepared = False | [
"def",
"reset",
"(",
"cls",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"cls",
".",
"local",
".",
"tchannel",
"=",
"None",
"cls",
".",
"args",
"=",
"None",
"cls",
".",
"kwargs",
"=",
"None",
"cls",
".",
"prepared",
"=",
"False"
] | Undo call to prepare, useful for testing. | [
"Undo",
"call",
"to",
"prepare",
"useful",
"for",
"testing",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/singleton.py#L54-L59 | train |
uber/tchannel-python | tchannel/singleton.py | TChannel.get_instance | def get_instance(cls):
"""Get a configured, thread-safe, singleton TChannel instance.
:returns tchannel.TChannel:
"""
if not cls.prepared:
raise SingletonNotPreparedError(
"prepare must be called before get_instance"
)
if hasattr(cls.loca... | python | def get_instance(cls):
"""Get a configured, thread-safe, singleton TChannel instance.
:returns tchannel.TChannel:
"""
if not cls.prepared:
raise SingletonNotPreparedError(
"prepare must be called before get_instance"
)
if hasattr(cls.loca... | [
"def",
"get_instance",
"(",
"cls",
")",
":",
"if",
"not",
"cls",
".",
"prepared",
":",
"raise",
"SingletonNotPreparedError",
"(",
"\"prepare must be called before get_instance\"",
")",
"if",
"hasattr",
"(",
"cls",
".",
"local",
",",
"'tchannel'",
")",
"and",
"cl... | Get a configured, thread-safe, singleton TChannel instance.
:returns tchannel.TChannel: | [
"Get",
"a",
"configured",
"thread",
"-",
"safe",
"singleton",
"TChannel",
"instance",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/singleton.py#L62-L77 | train |
uber/tchannel-python | tchannel/tornado/dispatch.py | RequestDispatcher.handle_pre_call | def handle_pre_call(self, message, connection):
"""Handle incoming request message including CallRequestMessage and
CallRequestContinueMessage
This method will build the User friendly request object based on the
incoming messages.
It passes all the messages into the message_fac... | python | def handle_pre_call(self, message, connection):
"""Handle incoming request message including CallRequestMessage and
CallRequestContinueMessage
This method will build the User friendly request object based on the
incoming messages.
It passes all the messages into the message_fac... | [
"def",
"handle_pre_call",
"(",
"self",
",",
"message",
",",
"connection",
")",
":",
"req",
"=",
"None",
"try",
":",
"req",
"=",
"connection",
".",
"request_message_factory",
".",
"build",
"(",
"message",
")",
"if",
"req",
":",
"self",
".",
"handle_call",
... | Handle incoming request message including CallRequestMessage and
CallRequestContinueMessage
This method will build the User friendly request object based on the
incoming messages.
It passes all the messages into the message_factory to build the init
request object. Only when it... | [
"Handle",
"incoming",
"request",
"message",
"including",
"CallRequestMessage",
"and",
"CallRequestContinueMessage"
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/dispatch.py#L89-L117 | train |
uber/tchannel-python | tchannel/tornado/dispatch.py | RequestDispatcher.register | def register(
self,
rule,
handler,
req_serializer=None,
resp_serializer=None
):
"""Register a new endpoint with the given name.
.. code-block:: python
@dispatcher.register('is_healthy')
def check_health(request, re... | python | def register(
self,
rule,
handler,
req_serializer=None,
resp_serializer=None
):
"""Register a new endpoint with the given name.
.. code-block:: python
@dispatcher.register('is_healthy')
def check_health(request, re... | [
"def",
"register",
"(",
"self",
",",
"rule",
",",
"handler",
",",
"req_serializer",
"=",
"None",
",",
"resp_serializer",
"=",
"None",
")",
":",
"assert",
"handler",
",",
"\"handler must not be None\"",
"req_serializer",
"=",
"req_serializer",
"or",
"RawSerializer"... | Register a new endpoint with the given name.
.. code-block:: python
@dispatcher.register('is_healthy')
def check_health(request, response):
# ...
:param rule:
Name of the endpoint. Incoming Call Requests must have this as
``arg1`` to dis... | [
"Register",
"a",
"new",
"endpoint",
"with",
"the",
"given",
"name",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/dispatch.py#L291-L329 | train |
uber/tchannel-python | tchannel/messages/common.py | generate_checksum | def generate_checksum(message, previous_csum=0):
"""Generate checksum for messages with
CALL_REQ, CALL_REQ_CONTINUE,
CALL_RES,CALL_RES_CONTINUE types.
:param message: outgoing message
:param previous_csum: accumulated checksum value
"""
if message.message_type in CHECKSUM_MSG_TYPES:... | python | def generate_checksum(message, previous_csum=0):
"""Generate checksum for messages with
CALL_REQ, CALL_REQ_CONTINUE,
CALL_RES,CALL_RES_CONTINUE types.
:param message: outgoing message
:param previous_csum: accumulated checksum value
"""
if message.message_type in CHECKSUM_MSG_TYPES:... | [
"def",
"generate_checksum",
"(",
"message",
",",
"previous_csum",
"=",
"0",
")",
":",
"if",
"message",
".",
"message_type",
"in",
"CHECKSUM_MSG_TYPES",
":",
"csum",
"=",
"compute_checksum",
"(",
"message",
".",
"checksum",
"[",
"0",
"]",
",",
"message",
".",... | Generate checksum for messages with
CALL_REQ, CALL_REQ_CONTINUE,
CALL_RES,CALL_RES_CONTINUE types.
:param message: outgoing message
:param previous_csum: accumulated checksum value | [
"Generate",
"checksum",
"for",
"messages",
"with",
"CALL_REQ",
"CALL_REQ_CONTINUE",
"CALL_RES",
"CALL_RES_CONTINUE",
"types",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/messages/common.py#L138-L153 | train |
uber/tchannel-python | tchannel/messages/common.py | verify_checksum | def verify_checksum(message, previous_csum=0):
"""Verify checksum for incoming message.
:param message: incoming message
:param previous_csum: accumulated checksum value
:return return True if message checksum type is None
or checksum is correct
"""
if message.message_type in CHECKSUM_MSG_... | python | def verify_checksum(message, previous_csum=0):
"""Verify checksum for incoming message.
:param message: incoming message
:param previous_csum: accumulated checksum value
:return return True if message checksum type is None
or checksum is correct
"""
if message.message_type in CHECKSUM_MSG_... | [
"def",
"verify_checksum",
"(",
"message",
",",
"previous_csum",
"=",
"0",
")",
":",
"if",
"message",
".",
"message_type",
"in",
"CHECKSUM_MSG_TYPES",
":",
"csum",
"=",
"compute_checksum",
"(",
"message",
".",
"checksum",
"[",
"0",
"]",
",",
"message",
".",
... | Verify checksum for incoming message.
:param message: incoming message
:param previous_csum: accumulated checksum value
:return return True if message checksum type is None
or checksum is correct | [
"Verify",
"checksum",
"for",
"incoming",
"message",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/messages/common.py#L156-L177 | train |
uber/tchannel-python | tchannel/tornado/hyperbahn.py | Advertiser.start | def start(self):
"""Starts the advertise loop.
Returns the result of the first ad request.
"""
if self.running:
raise Exception('Advertiser is already running')
if self.io_loop is None:
self.io_loop = tornado.ioloop.IOLoop.current()
self.running ... | python | def start(self):
"""Starts the advertise loop.
Returns the result of the first ad request.
"""
if self.running:
raise Exception('Advertiser is already running')
if self.io_loop is None:
self.io_loop = tornado.ioloop.IOLoop.current()
self.running ... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"running",
":",
"raise",
"Exception",
"(",
"'Advertiser is already running'",
")",
"if",
"self",
".",
"io_loop",
"is",
"None",
":",
"self",
".",
"io_loop",
"=",
"tornado",
".",
"ioloop",
".",
"IOL... | Starts the advertise loop.
Returns the result of the first ad request. | [
"Starts",
"the",
"advertise",
"loop",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/hyperbahn.py#L81-L94 | train |
uber/tchannel-python | tchannel/tornado/hyperbahn.py | Advertiser._schedule_ad | def _schedule_ad(self, delay=None, response_future=None):
"""Schedules an ``ad`` request.
:param delay:
Time in seconds to wait before making the ``ad`` request. Defaults
to self.interval_secs. Regardless of value, a jitter of
self.interval_max_jitter_secs is applied... | python | def _schedule_ad(self, delay=None, response_future=None):
"""Schedules an ``ad`` request.
:param delay:
Time in seconds to wait before making the ``ad`` request. Defaults
to self.interval_secs. Regardless of value, a jitter of
self.interval_max_jitter_secs is applied... | [
"def",
"_schedule_ad",
"(",
"self",
",",
"delay",
"=",
"None",
",",
"response_future",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"running",
":",
"return",
"if",
"delay",
"is",
"None",
":",
"delay",
"=",
"self",
".",
"interval_secs",
"delay",
"+=... | Schedules an ``ad`` request.
:param delay:
Time in seconds to wait before making the ``ad`` request. Defaults
to self.interval_secs. Regardless of value, a jitter of
self.interval_max_jitter_secs is applied to this.
:param response_future:
If non-None, th... | [
"Schedules",
"an",
"ad",
"request",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/hyperbahn.py#L102-L121 | train |
uber/tchannel-python | tchannel/tornado/tombstone.py | Cemetery.add | def add(self, id, ttl_secs):
"""Adds a new request to the Cemetery that is known to have timed out.
The request will be forgotten after ``ttl_secs + ttl_offset_secs``
seconds.
:param id:
ID of the request
:param ttl_secs:
TTL of the request (in seconds)
... | python | def add(self, id, ttl_secs):
"""Adds a new request to the Cemetery that is known to have timed out.
The request will be forgotten after ``ttl_secs + ttl_offset_secs``
seconds.
:param id:
ID of the request
:param ttl_secs:
TTL of the request (in seconds)
... | [
"def",
"add",
"(",
"self",
",",
"id",
",",
"ttl_secs",
")",
":",
"ttl_secs",
"=",
"min",
"(",
"ttl_secs",
"+",
"self",
".",
"ttl_offset_secs",
",",
"self",
".",
"max_ttl_secs",
")",
"self",
".",
"_tombstones",
"[",
"id",
"]",
"=",
"IOLoop",
".",
"cur... | Adds a new request to the Cemetery that is known to have timed out.
The request will be forgotten after ``ttl_secs + ttl_offset_secs``
seconds.
:param id:
ID of the request
:param ttl_secs:
TTL of the request (in seconds) | [
"Adds",
"a",
"new",
"request",
"to",
"the",
"Cemetery",
"that",
"is",
"known",
"to",
"have",
"timed",
"out",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tombstone.py#L83-L97 | train |
uber/tchannel-python | tchannel/tornado/tombstone.py | Cemetery.clear | def clear(self):
"""Forget about all requests."""
io_loop = IOLoop.current()
while self._tombstones:
_, req_timeout = self._tombstones.popitem()
io_loop.remove_timeout(req_timeout) | python | def clear(self):
"""Forget about all requests."""
io_loop = IOLoop.current()
while self._tombstones:
_, req_timeout = self._tombstones.popitem()
io_loop.remove_timeout(req_timeout) | [
"def",
"clear",
"(",
"self",
")",
":",
"io_loop",
"=",
"IOLoop",
".",
"current",
"(",
")",
"while",
"self",
".",
"_tombstones",
":",
"_",
",",
"req_timeout",
"=",
"self",
".",
"_tombstones",
".",
"popitem",
"(",
")",
"io_loop",
".",
"remove_timeout",
"... | Forget about all requests. | [
"Forget",
"about",
"all",
"requests",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tombstone.py#L103-L108 | train |
uber/tchannel-python | tchannel/tornado/response.py | Response.get_header | def get_header(self):
"""Get the header value from the response.
:return: a future contains the deserialized value of header
"""
raw_header = yield get_arg(self, 1)
if not self.serializer:
raise tornado.gen.Return(raw_header)
else:
header = self.s... | python | def get_header(self):
"""Get the header value from the response.
:return: a future contains the deserialized value of header
"""
raw_header = yield get_arg(self, 1)
if not self.serializer:
raise tornado.gen.Return(raw_header)
else:
header = self.s... | [
"def",
"get_header",
"(",
"self",
")",
":",
"raw_header",
"=",
"yield",
"get_arg",
"(",
"self",
",",
"1",
")",
"if",
"not",
"self",
".",
"serializer",
":",
"raise",
"tornado",
".",
"gen",
".",
"Return",
"(",
"raw_header",
")",
"else",
":",
"header",
... | Get the header value from the response.
:return: a future contains the deserialized value of header | [
"Get",
"the",
"header",
"value",
"from",
"the",
"response",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/response.py#L109-L119 | train |
uber/tchannel-python | tchannel/tornado/response.py | Response.get_body | def get_body(self):
"""Get the body value from the response.
:return: a future contains the deserialized value of body
"""
raw_body = yield get_arg(self, 2)
if not self.serializer:
raise tornado.gen.Return(raw_body)
else:
body = self.serializer.d... | python | def get_body(self):
"""Get the body value from the response.
:return: a future contains the deserialized value of body
"""
raw_body = yield get_arg(self, 2)
if not self.serializer:
raise tornado.gen.Return(raw_body)
else:
body = self.serializer.d... | [
"def",
"get_body",
"(",
"self",
")",
":",
"raw_body",
"=",
"yield",
"get_arg",
"(",
"self",
",",
"2",
")",
"if",
"not",
"self",
".",
"serializer",
":",
"raise",
"tornado",
".",
"gen",
".",
"Return",
"(",
"raw_body",
")",
"else",
":",
"body",
"=",
"... | Get the body value from the response.
:return: a future contains the deserialized value of body | [
"Get",
"the",
"body",
"value",
"from",
"the",
"response",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/response.py#L122-L133 | train |
uber/tchannel-python | tchannel/tornado/response.py | Response.set_body_s | def set_body_s(self, stream):
"""Set customized body stream.
Note: the body stream can only be changed before the stream
is consumed.
:param stream: InMemStream/PipeStream for body
:except TChannelError:
Raise TChannelError if the stream is being sent when you try
... | python | def set_body_s(self, stream):
"""Set customized body stream.
Note: the body stream can only be changed before the stream
is consumed.
:param stream: InMemStream/PipeStream for body
:except TChannelError:
Raise TChannelError if the stream is being sent when you try
... | [
"def",
"set_body_s",
"(",
"self",
",",
"stream",
")",
":",
"if",
"self",
".",
"argstreams",
"[",
"2",
"]",
".",
"state",
"==",
"StreamState",
".",
"init",
":",
"self",
".",
"argstreams",
"[",
"2",
"]",
"=",
"stream",
"else",
":",
"raise",
"TChannelEr... | Set customized body stream.
Note: the body stream can only be changed before the stream
is consumed.
:param stream: InMemStream/PipeStream for body
:except TChannelError:
Raise TChannelError if the stream is being sent when you try
to change the stream. | [
"Set",
"customized",
"body",
"stream",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/response.py#L135-L151 | train |
uber/tchannel-python | tchannel/tornado/response.py | Response.set_header_s | def set_header_s(self, stream):
"""Set customized header stream.
Note: the header stream can only be changed before the stream
is consumed.
:param stream: InMemStream/PipeStream for header
:except TChannelError:
Raise TChannelError if the stream is being sent when ... | python | def set_header_s(self, stream):
"""Set customized header stream.
Note: the header stream can only be changed before the stream
is consumed.
:param stream: InMemStream/PipeStream for header
:except TChannelError:
Raise TChannelError if the stream is being sent when ... | [
"def",
"set_header_s",
"(",
"self",
",",
"stream",
")",
":",
"if",
"self",
".",
"argstreams",
"[",
"1",
"]",
".",
"state",
"==",
"StreamState",
".",
"init",
":",
"self",
".",
"argstreams",
"[",
"1",
"]",
"=",
"stream",
"else",
":",
"raise",
"TChannel... | Set customized header stream.
Note: the header stream can only be changed before the stream
is consumed.
:param stream: InMemStream/PipeStream for header
:except TChannelError:
Raise TChannelError if the stream is being sent when you try
to change the stream. | [
"Set",
"customized",
"header",
"stream",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/response.py#L153-L170 | train |
uber/tchannel-python | tchannel/tornado/connection.py | read_message | def read_message(stream):
"""Reads a message from the given IOStream.
:param IOStream stream:
IOStream to read from.
"""
answer = tornado.gen.Future()
io_loop = IOLoop.current()
def on_error(future):
log.info('Failed to read data: %s', future.exception())
return answer.... | python | def read_message(stream):
"""Reads a message from the given IOStream.
:param IOStream stream:
IOStream to read from.
"""
answer = tornado.gen.Future()
io_loop = IOLoop.current()
def on_error(future):
log.info('Failed to read data: %s', future.exception())
return answer.... | [
"def",
"read_message",
"(",
"stream",
")",
":",
"answer",
"=",
"tornado",
".",
"gen",
".",
"Future",
"(",
")",
"io_loop",
"=",
"IOLoop",
".",
"current",
"(",
")",
"def",
"on_error",
"(",
"future",
")",
":",
"log",
".",
"info",
"(",
"'Failed to read dat... | Reads a message from the given IOStream.
:param IOStream stream:
IOStream to read from. | [
"Reads",
"a",
"message",
"from",
"the",
"given",
"IOStream",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L905-L956 | train |
uber/tchannel-python | tchannel/tornado/connection.py | TornadoConnection.set_close_callback | def set_close_callback(self, cb):
"""Specify a function to be called when this connection is closed.
:param cb:
A callable that takes no arguments. This callable will be called
when this connection is closed.
"""
assert self._close_cb is None, (
'A cl... | python | def set_close_callback(self, cb):
"""Specify a function to be called when this connection is closed.
:param cb:
A callable that takes no arguments. This callable will be called
when this connection is closed.
"""
assert self._close_cb is None, (
'A cl... | [
"def",
"set_close_callback",
"(",
"self",
",",
"cb",
")",
":",
"assert",
"self",
".",
"_close_cb",
"is",
"None",
",",
"(",
"'A close_callback has already been set for this connection.'",
")",
"self",
".",
"_close_cb",
"=",
"stack_context",
".",
"wrap",
"(",
"cb",
... | Specify a function to be called when this connection is closed.
:param cb:
A callable that takes no arguments. This callable will be called
when this connection is closed. | [
"Specify",
"a",
"function",
"to",
"be",
"called",
"when",
"this",
"connection",
"is",
"closed",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L156-L168 | train |
uber/tchannel-python | tchannel/tornado/connection.py | TornadoConnection.send | def send(self, message):
"""Send the given message up the wire.
Use this for messages which have a response message.
:param message:
Message to send
:returns:
A Future containing the response for the message
"""
assert self._handshake_performed, "... | python | def send(self, message):
"""Send the given message up the wire.
Use this for messages which have a response message.
:param message:
Message to send
:returns:
A Future containing the response for the message
"""
assert self._handshake_performed, "... | [
"def",
"send",
"(",
"self",
",",
"message",
")",
":",
"assert",
"self",
".",
"_handshake_performed",
",",
"\"Perform a handshake first.\"",
"assert",
"message",
".",
"message_type",
"in",
"self",
".",
"CALL_REQ_TYPES",
",",
"(",
"\"Message '%s' can't use send\"",
"%... | Send the given message up the wire.
Use this for messages which have a response message.
:param message:
Message to send
:returns:
A Future containing the response for the message | [
"Send",
"the",
"given",
"message",
"up",
"the",
"wire",
".",
"Use",
"this",
"for",
"messages",
"which",
"have",
"a",
"response",
"message",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L278-L300 | train |
uber/tchannel-python | tchannel/tornado/connection.py | TornadoConnection.write | def write(self, message):
"""Writes the given message up the wire.
Does not expect a response back for the message.
:param message:
Message to write.
"""
message.id = message.id or self.writer.next_message_id()
if message.message_type in self.CALL_REQ_TYPES... | python | def write(self, message):
"""Writes the given message up the wire.
Does not expect a response back for the message.
:param message:
Message to write.
"""
message.id = message.id or self.writer.next_message_id()
if message.message_type in self.CALL_REQ_TYPES... | [
"def",
"write",
"(",
"self",
",",
"message",
")",
":",
"message",
".",
"id",
"=",
"message",
".",
"id",
"or",
"self",
".",
"writer",
".",
"next_message_id",
"(",
")",
"if",
"message",
".",
"message_type",
"in",
"self",
".",
"CALL_REQ_TYPES",
":",
"mess... | Writes the given message up the wire.
Does not expect a response back for the message.
:param message:
Message to write. | [
"Writes",
"the",
"given",
"message",
"up",
"the",
"wire",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L302-L318 | train |
uber/tchannel-python | tchannel/tornado/connection.py | TornadoConnection.initiate_handshake | def initiate_handshake(self, headers, timeout=None):
"""Initiate a handshake with the remote host.
:param headers:
A dictionary of headers to send.
:returns:
A future that resolves (with a value of None) when the handshake
is complete.
"""
io_... | python | def initiate_handshake(self, headers, timeout=None):
"""Initiate a handshake with the remote host.
:param headers:
A dictionary of headers to send.
:returns:
A future that resolves (with a value of None) when the handshake
is complete.
"""
io_... | [
"def",
"initiate_handshake",
"(",
"self",
",",
"headers",
",",
"timeout",
"=",
"None",
")",
":",
"io_loop",
"=",
"IOLoop",
".",
"current",
"(",
")",
"timeout",
"=",
"timeout",
"or",
"DEFAULT_INIT_TIMEOUT_SECS",
"self",
".",
"writer",
".",
"put",
"(",
"mess... | Initiate a handshake with the remote host.
:param headers:
A dictionary of headers to send.
:returns:
A future that resolves (with a value of None) when the handshake
is complete. | [
"Initiate",
"a",
"handshake",
"with",
"the",
"remote",
"host",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L359-L402 | train |
uber/tchannel-python | tchannel/tornado/connection.py | TornadoConnection.expect_handshake | def expect_handshake(self, headers):
"""Expect a handshake from the remote host.
:param headers:
Headers to respond with
:returns:
A future that resolves (with a value of None) when the handshake
is complete.
"""
init_req = yield self.reader.g... | python | def expect_handshake(self, headers):
"""Expect a handshake from the remote host.
:param headers:
Headers to respond with
:returns:
A future that resolves (with a value of None) when the handshake
is complete.
"""
init_req = yield self.reader.g... | [
"def",
"expect_handshake",
"(",
"self",
",",
"headers",
")",
":",
"init_req",
"=",
"yield",
"self",
".",
"reader",
".",
"get",
"(",
")",
"if",
"init_req",
".",
"message_type",
"!=",
"Types",
".",
"INIT_REQ",
":",
"raise",
"errors",
".",
"UnexpectedError",
... | Expect a handshake from the remote host.
:param headers:
Headers to respond with
:returns:
A future that resolves (with a value of None) when the handshake
is complete. | [
"Expect",
"a",
"handshake",
"from",
"the",
"remote",
"host",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L405-L431 | train |
uber/tchannel-python | tchannel/tornado/connection.py | TornadoConnection.outgoing | def outgoing(cls, hostport, process_name=None, serve_hostport=None,
handler=None, tchannel=None):
"""Initiate a new connection to the given host.
:param hostport:
String in the form ``$host:$port`` specifying the target host
:param process_name:
Process ... | python | def outgoing(cls, hostport, process_name=None, serve_hostport=None,
handler=None, tchannel=None):
"""Initiate a new connection to the given host.
:param hostport:
String in the form ``$host:$port`` specifying the target host
:param process_name:
Process ... | [
"def",
"outgoing",
"(",
"cls",
",",
"hostport",
",",
"process_name",
"=",
"None",
",",
"serve_hostport",
"=",
"None",
",",
"handler",
"=",
"None",
",",
"tchannel",
"=",
"None",
")",
":",
"host",
",",
"port",
"=",
"hostport",
".",
"rsplit",
"(",
"\":\""... | Initiate a new connection to the given host.
:param hostport:
String in the form ``$host:$port`` specifying the target host
:param process_name:
Process name of the entity making the connection.
:param serve_hostport:
String in the form ``$host:$port`` specif... | [
"Initiate",
"a",
"new",
"connection",
"to",
"the",
"given",
"host",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L452-L501 | train |
uber/tchannel-python | tchannel/tornado/connection.py | TornadoConnection.serve | def serve(self, handler):
"""Serve calls over this connection using the given RequestHandler.
:param handler:
RequestHandler to process the requests through
:return:
A Future that resolves (to None) once the loop is done running --
which happens once this con... | python | def serve(self, handler):
"""Serve calls over this connection using the given RequestHandler.
:param handler:
RequestHandler to process the requests through
:return:
A Future that resolves (to None) once the loop is done running --
which happens once this con... | [
"def",
"serve",
"(",
"self",
",",
"handler",
")",
":",
"assert",
"handler",
",",
"\"handler is required\"",
"while",
"not",
"self",
".",
"closed",
":",
"message",
"=",
"yield",
"self",
".",
"await",
"(",
")",
"try",
":",
"handler",
"(",
"message",
",",
... | Serve calls over this connection using the given RequestHandler.
:param handler:
RequestHandler to process the requests through
:return:
A Future that resolves (to None) once the loop is done running --
which happens once this connection is closed. | [
"Serve",
"calls",
"over",
"this",
"connection",
"using",
"the",
"given",
"RequestHandler",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L504-L522 | train |
uber/tchannel-python | tchannel/tornado/connection.py | TornadoConnection.send_error | def send_error(self, error):
"""Convenience method for writing Error frames up the wire.
:param error:
TChannel Error. :py:class`tchannel.errors.TChannelError`.
:returns:
A future that resolves when the write finishes.
"""
error_message = build_raw_error... | python | def send_error(self, error):
"""Convenience method for writing Error frames up the wire.
:param error:
TChannel Error. :py:class`tchannel.errors.TChannelError`.
:returns:
A future that resolves when the write finishes.
"""
error_message = build_raw_error... | [
"def",
"send_error",
"(",
"self",
",",
"error",
")",
":",
"error_message",
"=",
"build_raw_error_message",
"(",
"error",
")",
"write_future",
"=",
"self",
".",
"writer",
".",
"put",
"(",
"error_message",
")",
"write_future",
".",
"add_done_callback",
"(",
"lam... | Convenience method for writing Error frames up the wire.
:param error:
TChannel Error. :py:class`tchannel.errors.TChannelError`.
:returns:
A future that resolves when the write finishes. | [
"Convenience",
"method",
"for",
"writing",
"Error",
"frames",
"up",
"the",
"wire",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L524-L543 | train |
uber/tchannel-python | tchannel/tornado/connection.py | StreamConnection.stream_request | def stream_request(self, request, out_future):
"""send the given request and response is not required"""
request.close_argstreams()
def on_done(future):
if future.exception() and out_future.running():
out_future.set_exc_info(future.exc_info())
request.clo... | python | def stream_request(self, request, out_future):
"""send the given request and response is not required"""
request.close_argstreams()
def on_done(future):
if future.exception() and out_future.running():
out_future.set_exc_info(future.exc_info())
request.clo... | [
"def",
"stream_request",
"(",
"self",
",",
"request",
",",
"out_future",
")",
":",
"request",
".",
"close_argstreams",
"(",
")",
"def",
"on_done",
"(",
"future",
")",
":",
"if",
"future",
".",
"exception",
"(",
")",
"and",
"out_future",
".",
"running",
"... | send the given request and response is not required | [
"send",
"the",
"given",
"request",
"and",
"response",
"is",
"not",
"required"
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L646-L657 | train |
uber/tchannel-python | tchannel/tornado/connection.py | StreamConnection.send_request | def send_request(self, request):
"""Send the given request and response is required.
Use this for messages which have a response message.
:param request:
request to send
:returns:
A Future containing the response for the request
"""
assert self._... | python | def send_request(self, request):
"""Send the given request and response is required.
Use this for messages which have a response message.
:param request:
request to send
:returns:
A Future containing the response for the request
"""
assert self._... | [
"def",
"send_request",
"(",
"self",
",",
"request",
")",
":",
"assert",
"self",
".",
"_handshake_performed",
",",
"\"Perform a handshake first.\"",
"assert",
"request",
".",
"id",
"not",
"in",
"self",
".",
"_outbound_pending_call",
",",
"(",
"\"Message ID '%d' alrea... | Send the given request and response is required.
Use this for messages which have a response message.
:param request:
request to send
:returns:
A Future containing the response for the request | [
"Send",
"the",
"given",
"request",
"and",
"response",
"is",
"required",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L659-L693 | train |
uber/tchannel-python | tchannel/tornado/connection.py | StreamConnection._add_timeout | def _add_timeout(self, request, future):
"""Adds a timeout for the given request to the given future."""
io_loop = IOLoop.current()
t = io_loop.call_later(
request.ttl,
self._request_timed_out,
request.id,
request.service,
request.ttl,
... | python | def _add_timeout(self, request, future):
"""Adds a timeout for the given request to the given future."""
io_loop = IOLoop.current()
t = io_loop.call_later(
request.ttl,
self._request_timed_out,
request.id,
request.service,
request.ttl,
... | [
"def",
"_add_timeout",
"(",
"self",
",",
"request",
",",
"future",
")",
":",
"io_loop",
"=",
"IOLoop",
".",
"current",
"(",
")",
"t",
"=",
"io_loop",
".",
"call_later",
"(",
"request",
".",
"ttl",
",",
"self",
".",
"_request_timed_out",
",",
"request",
... | Adds a timeout for the given request to the given future. | [
"Adds",
"a",
"timeout",
"for",
"the",
"given",
"request",
"to",
"the",
"given",
"future",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L713-L724 | train |
uber/tchannel-python | tchannel/tornado/connection.py | Reader.get | def get(self):
"""Receive the next message off the wire.
:returns:
A Future that resolves to the next message off the wire.
"""
if not self.filling:
self.fill()
answer = tornado.gen.Future()
def _on_result(future):
if future.exceptio... | python | def get(self):
"""Receive the next message off the wire.
:returns:
A Future that resolves to the next message off the wire.
"""
if not self.filling:
self.fill()
answer = tornado.gen.Future()
def _on_result(future):
if future.exceptio... | [
"def",
"get",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"filling",
":",
"self",
".",
"fill",
"(",
")",
"answer",
"=",
"tornado",
".",
"gen",
".",
"Future",
"(",
")",
"def",
"_on_result",
"(",
"future",
")",
":",
"if",
"future",
".",
"excep... | Receive the next message off the wire.
:returns:
A Future that resolves to the next message off the wire. | [
"Receive",
"the",
"next",
"message",
"off",
"the",
"wire",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L777-L799 | train |
uber/tchannel-python | tchannel/tornado/connection.py | Writer.put | def put(self, message):
"""Enqueues the given message for writing to the wire.
The message must be small enough to fit in a single frame.
"""
if self.draining is False:
self.drain()
return self._enqueue(message) | python | def put(self, message):
"""Enqueues the given message for writing to the wire.
The message must be small enough to fit in a single frame.
"""
if self.draining is False:
self.drain()
return self._enqueue(message) | [
"def",
"put",
"(",
"self",
",",
"message",
")",
":",
"if",
"self",
".",
"draining",
"is",
"False",
":",
"self",
".",
"drain",
"(",
")",
"return",
"self",
".",
"_enqueue",
"(",
"message",
")"
] | Enqueues the given message for writing to the wire.
The message must be small enough to fit in a single frame. | [
"Enqueues",
"the",
"given",
"message",
"for",
"writing",
"to",
"the",
"wire",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L850-L858 | train |
uber/tchannel-python | tchannel/tornado/tchannel.py | TChannel.advertise | def advertise(
self,
routers=None,
name=None,
timeout=None,
router_file=None,
jitter=None,
):
"""Make a service available on the Hyperbahn routing mesh.
This will make contact with a Hyperbahn host from a list of known
Hyperbahn routers. Addit... | python | def advertise(
self,
routers=None,
name=None,
timeout=None,
router_file=None,
jitter=None,
):
"""Make a service available on the Hyperbahn routing mesh.
This will make contact with a Hyperbahn host from a list of known
Hyperbahn routers. Addit... | [
"def",
"advertise",
"(",
"self",
",",
"routers",
"=",
"None",
",",
"name",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"router_file",
"=",
"None",
",",
"jitter",
"=",
"None",
",",
")",
":",
"name",
"=",
"name",
"or",
"self",
".",
"name",
"if",
... | Make a service available on the Hyperbahn routing mesh.
This will make contact with a Hyperbahn host from a list of known
Hyperbahn routers. Additional Hyperbahn connections will be established
once contact has been made with the network.
:param router:
A seed list of addre... | [
"Make",
"a",
"service",
"available",
"on",
"the",
"Hyperbahn",
"routing",
"mesh",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tchannel.py#L189-L232 | train |
uber/tchannel-python | tchannel/tornado/tchannel.py | TChannel.request | def request(self,
hostport=None,
service=None,
arg_scheme=None,
retry=None,
**kwargs):
"""Initiate a new request through this TChannel.
:param hostport:
Host to which the request will be made. If unspecified, a ... | python | def request(self,
hostport=None,
service=None,
arg_scheme=None,
retry=None,
**kwargs):
"""Initiate a new request through this TChannel.
:param hostport:
Host to which the request will be made. If unspecified, a ... | [
"def",
"request",
"(",
"self",
",",
"hostport",
"=",
"None",
",",
"service",
"=",
"None",
",",
"arg_scheme",
"=",
"None",
",",
"retry",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"peers",
".",
"request",
"(",
"hostport",
"=",
... | Initiate a new request through this TChannel.
:param hostport:
Host to which the request will be made. If unspecified, a random
known peer will be picked. This is not necessary if using
Hyperbahn.
:param service:
The name of a service available on Hyperb... | [
"Initiate",
"a",
"new",
"request",
"through",
"this",
"TChannel",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tchannel.py#L262-L296 | train |
uber/tchannel-python | tchannel/tornado/tchannel.py | TChannel.listen | def listen(self, port=None):
"""Start listening for incoming connections.
A request handler must have already been specified with
``TChannel.host``.
:param port:
An explicit port to listen on. This is unnecessary when advertising
on Hyperbahn.
:returns:... | python | def listen(self, port=None):
"""Start listening for incoming connections.
A request handler must have already been specified with
``TChannel.host``.
:param port:
An explicit port to listen on. This is unnecessary when advertising
on Hyperbahn.
:returns:... | [
"def",
"listen",
"(",
"self",
",",
"port",
"=",
"None",
")",
":",
"if",
"self",
".",
"is_listening",
"(",
")",
":",
"raise",
"AlreadyListeningError",
"(",
"\"listen has already been called\"",
")",
"if",
"port",
":",
"assert",
"not",
"self",
".",
"_port",
... | Start listening for incoming connections.
A request handler must have already been specified with
``TChannel.host``.
:param port:
An explicit port to listen on. This is unnecessary when advertising
on Hyperbahn.
:returns:
Returns immediately.
... | [
"Start",
"listening",
"for",
"incoming",
"connections",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tchannel.py#L298-L350 | train |
uber/tchannel-python | tchannel/tornado/tchannel.py | TChannel._register_simple | def _register_simple(self, endpoint, scheme, f):
"""Register a simple endpoint with this TChannel.
:param endpoint:
Name of the endpoint being registered.
:param scheme:
Name of the arg scheme under which the endpoint will be
registered.
:param f:
... | python | def _register_simple(self, endpoint, scheme, f):
"""Register a simple endpoint with this TChannel.
:param endpoint:
Name of the endpoint being registered.
:param scheme:
Name of the arg scheme under which the endpoint will be
registered.
:param f:
... | [
"def",
"_register_simple",
"(",
"self",
",",
"endpoint",
",",
"scheme",
",",
"f",
")",
":",
"assert",
"scheme",
"in",
"DEFAULT_NAMES",
",",
"(",
"\"Unsupported arg scheme %s\"",
"%",
"scheme",
")",
"if",
"scheme",
"==",
"JSON",
":",
"req_serializer",
"=",
"J... | Register a simple endpoint with this TChannel.
:param endpoint:
Name of the endpoint being registered.
:param scheme:
Name of the arg scheme under which the endpoint will be
registered.
:param f:
Callable handler for the endpoint. | [
"Register",
"a",
"simple",
"endpoint",
"with",
"this",
"TChannel",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tchannel.py#L368-L387 | train |
uber/tchannel-python | tchannel/tornado/tchannel.py | TChannel._register_thrift | def _register_thrift(self, service_module, handler, **kwargs):
"""Register a Thrift endpoint on this TChannel.
:param service_module:
Reference to the Thrift-generated module for the service being
registered.
:param handler:
Handler for the endpoint
:... | python | def _register_thrift(self, service_module, handler, **kwargs):
"""Register a Thrift endpoint on this TChannel.
:param service_module:
Reference to the Thrift-generated module for the service being
registered.
:param handler:
Handler for the endpoint
:... | [
"def",
"_register_thrift",
"(",
"self",
",",
"service_module",
",",
"handler",
",",
"**",
"kwargs",
")",
":",
"import",
"tchannel",
".",
"thrift",
"as",
"thrift",
"thrift",
".",
"register",
"(",
"self",
".",
"_handler",
",",
"service_module",
",",
"handler",... | Register a Thrift endpoint on this TChannel.
:param service_module:
Reference to the Thrift-generated module for the service being
registered.
:param handler:
Handler for the endpoint
:param method:
Name of the Thrift method being registered. If o... | [
"Register",
"a",
"Thrift",
"endpoint",
"on",
"this",
"TChannel",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tchannel.py#L389-L409 | train |
uber/tchannel-python | tchannel/tornado/tchannel.py | TChannel.register | def register(self, endpoint, scheme=None, handler=None, **kwargs):
"""Register a handler with this TChannel.
This may be used as a decorator:
.. code-block:: python
app = TChannel(name='bar')
@app.register("hello", "json")
def hello_handler(request, respon... | python | def register(self, endpoint, scheme=None, handler=None, **kwargs):
"""Register a handler with this TChannel.
This may be used as a decorator:
.. code-block:: python
app = TChannel(name='bar')
@app.register("hello", "json")
def hello_handler(request, respon... | [
"def",
"register",
"(",
"self",
",",
"endpoint",
",",
"scheme",
"=",
"None",
",",
"handler",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"assert",
"endpoint",
"is",
"not",
"None",
",",
"\"endpoint is required\"",
"if",
"endpoint",
"is",
"TChannel",
".",
... | Register a handler with this TChannel.
This may be used as a decorator:
.. code-block:: python
app = TChannel(name='bar')
@app.register("hello", "json")
def hello_handler(request, response):
params = yield request.get_body()
Or as a functi... | [
"Register",
"a",
"handler",
"with",
"this",
"TChannel",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tchannel.py#L411-L477 | train |
uber/tchannel-python | tchannel/peer_heap.py | PeerHeap.lt | def lt(self, i, j):
"""Compare the priority of two peers.
Primary comparator will be the rank of each peer. If the ``rank`` is
same then compare the ``order``. The ``order`` attribute of the peer
tracks the heap push order of the peer. This help solve the imbalance
problem cause... | python | def lt(self, i, j):
"""Compare the priority of two peers.
Primary comparator will be the rank of each peer. If the ``rank`` is
same then compare the ``order``. The ``order`` attribute of the peer
tracks the heap push order of the peer. This help solve the imbalance
problem cause... | [
"def",
"lt",
"(",
"self",
",",
"i",
",",
"j",
")",
":",
"if",
"self",
".",
"peers",
"[",
"i",
"]",
".",
"rank",
"==",
"self",
".",
"peers",
"[",
"j",
"]",
".",
"rank",
":",
"return",
"self",
".",
"peers",
"[",
"i",
"]",
".",
"order",
"<",
... | Compare the priority of two peers.
Primary comparator will be the rank of each peer. If the ``rank`` is
same then compare the ``order``. The ``order`` attribute of the peer
tracks the heap push order of the peer. This help solve the imbalance
problem caused by randomization when deal wi... | [
"Compare",
"the",
"priority",
"of",
"two",
"peers",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/peer_heap.py#L63-L78 | train |
uber/tchannel-python | tchannel/peer_heap.py | PeerHeap.push_peer | def push_peer(self, peer):
"""Push a new peer into the heap"""
self.order += 1
peer.order = self.order + random.randint(0, self.size())
heap.push(self, peer) | python | def push_peer(self, peer):
"""Push a new peer into the heap"""
self.order += 1
peer.order = self.order + random.randint(0, self.size())
heap.push(self, peer) | [
"def",
"push_peer",
"(",
"self",
",",
"peer",
")",
":",
"self",
".",
"order",
"+=",
"1",
"peer",
".",
"order",
"=",
"self",
".",
"order",
"+",
"random",
".",
"randint",
"(",
"0",
",",
"self",
".",
"size",
"(",
")",
")",
"heap",
".",
"push",
"("... | Push a new peer into the heap | [
"Push",
"a",
"new",
"peer",
"into",
"the",
"heap"
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/peer_heap.py#L111-L116 | train |
uber/tchannel-python | tchannel/peer_heap.py | PeerHeap.add_and_shuffle | def add_and_shuffle(self, peer):
"""Push a new peer into the heap and shuffle the heap"""
self.push_peer(peer)
r = random.randint(0, self.size() - 1)
self.swap_order(peer.index, r) | python | def add_and_shuffle(self, peer):
"""Push a new peer into the heap and shuffle the heap"""
self.push_peer(peer)
r = random.randint(0, self.size() - 1)
self.swap_order(peer.index, r) | [
"def",
"add_and_shuffle",
"(",
"self",
",",
"peer",
")",
":",
"self",
".",
"push_peer",
"(",
"peer",
")",
"r",
"=",
"random",
".",
"randint",
"(",
"0",
",",
"self",
".",
"size",
"(",
")",
"-",
"1",
")",
"self",
".",
"swap_order",
"(",
"peer",
"."... | Push a new peer into the heap and shuffle the heap | [
"Push",
"a",
"new",
"peer",
"into",
"the",
"heap",
"and",
"shuffle",
"the",
"heap"
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/peer_heap.py#L118-L123 | train |
uber/tchannel-python | tchannel/peer_heap.py | PeerHeap.remove_peer | def remove_peer(self, peer):
"""Remove the peer from the heap.
Return: removed peer if peer exists. If peer's index is out of range,
raise IndexError.
"""
if peer.index < 0 or peer.index >= self.size():
raise IndexError('Peer index is out of range')
assert p... | python | def remove_peer(self, peer):
"""Remove the peer from the heap.
Return: removed peer if peer exists. If peer's index is out of range,
raise IndexError.
"""
if peer.index < 0 or peer.index >= self.size():
raise IndexError('Peer index is out of range')
assert p... | [
"def",
"remove_peer",
"(",
"self",
",",
"peer",
")",
":",
"if",
"peer",
".",
"index",
"<",
"0",
"or",
"peer",
".",
"index",
">=",
"self",
".",
"size",
"(",
")",
":",
"raise",
"IndexError",
"(",
"'Peer index is out of range'",
")",
"assert",
"peer",
"is... | Remove the peer from the heap.
Return: removed peer if peer exists. If peer's index is out of range,
raise IndexError. | [
"Remove",
"the",
"peer",
"from",
"the",
"heap",
"."
] | ee08cce6234f24fd2373774988186dd374306c43 | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/peer_heap.py#L136-L147 | train |
zamzterz/Flask-pyoidc | src/flask_pyoidc/pyoidc_facade.py | PyoidcFacade.token_request | def token_request(self, authorization_code):
"""
Makes a token request. If the 'token_endpoint' is not configured in the provider metadata, no request will
be made.
Args:
authorization_code (str): authorization code issued to client after user authorization
Returns... | python | def token_request(self, authorization_code):
"""
Makes a token request. If the 'token_endpoint' is not configured in the provider metadata, no request will
be made.
Args:
authorization_code (str): authorization code issued to client after user authorization
Returns... | [
"def",
"token_request",
"(",
"self",
",",
"authorization_code",
")",
":",
"if",
"not",
"self",
".",
"_client",
".",
"token_endpoint",
":",
"return",
"None",
"request",
"=",
"{",
"'grant_type'",
":",
"'authorization_code'",
",",
"'code'",
":",
"authorization_code... | Makes a token request. If the 'token_endpoint' is not configured in the provider metadata, no request will
be made.
Args:
authorization_code (str): authorization code issued to client after user authorization
Returns:
Union[AccessTokenResponse, TokenErrorResponse, None... | [
"Makes",
"a",
"token",
"request",
".",
"If",
"the",
"token_endpoint",
"is",
"not",
"configured",
"in",
"the",
"provider",
"metadata",
"no",
"request",
"will",
"be",
"made",
"."
] | 0dba3ce8931fe5e039c66d7d645331bdbb52960a | https://github.com/zamzterz/Flask-pyoidc/blob/0dba3ce8931fe5e039c66d7d645331bdbb52960a/src/flask_pyoidc/pyoidc_facade.py#L100-L140 | train |
robotframework/Rammbock | src/Rammbock/robotbackgroundlogger.py | BackgroundLogger.log_background_messages | def log_background_messages(self, name=None):
"""Forwards messages logged on background to Robot Framework log.
By default forwards all messages logged by all threads, but can be
limited to a certain thread by passing thread's name as an argument.
Logged messages are removed from the m... | python | def log_background_messages(self, name=None):
"""Forwards messages logged on background to Robot Framework log.
By default forwards all messages logged by all threads, but can be
limited to a certain thread by passing thread's name as an argument.
Logged messages are removed from the m... | [
"def",
"log_background_messages",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"name",
":",
"self",
".",
"_log_messages_by_thread",
"(",
"name",
")",
"else",
":",
"self",
".",
"_log_all_messages",
"(",
")"
] | Forwards messages logged on background to Robot Framework log.
By default forwards all messages logged by all threads, but can be
limited to a certain thread by passing thread's name as an argument.
Logged messages are removed from the message storage. | [
"Forwards",
"messages",
"logged",
"on",
"background",
"to",
"Robot",
"Framework",
"log",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/robotbackgroundlogger.py#L59-L71 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.reset_rammbock | def reset_rammbock(self):
"""Closes all connections, deletes all servers, clients, and protocols.
You should call this method before exiting your test run. This will
close all the connections and the ports will therefore be available for
reuse faster.
"""
for client in s... | python | def reset_rammbock(self):
"""Closes all connections, deletes all servers, clients, and protocols.
You should call this method before exiting your test run. This will
close all the connections and the ports will therefore be available for
reuse faster.
"""
for client in s... | [
"def",
"reset_rammbock",
"(",
"self",
")",
":",
"for",
"client",
"in",
"self",
".",
"_clients",
":",
"client",
".",
"close",
"(",
")",
"for",
"server",
"in",
"self",
".",
"_servers",
":",
"server",
".",
"close",
"(",
")",
"self",
".",
"_init_caches",
... | Closes all connections, deletes all servers, clients, and protocols.
You should call this method before exiting your test run. This will
close all the connections and the ports will therefore be available for
reuse faster. | [
"Closes",
"all",
"connections",
"deletes",
"all",
"servers",
"clients",
"and",
"protocols",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L136-L147 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.clear_message_streams | def clear_message_streams(self):
""" Resets streams and sockets of incoming messages.
You can use this method to reuse the same connections for several
consecutive test cases.
"""
for client in self._clients:
client.empty()
for server in self._servers:
... | python | def clear_message_streams(self):
""" Resets streams and sockets of incoming messages.
You can use this method to reuse the same connections for several
consecutive test cases.
"""
for client in self._clients:
client.empty()
for server in self._servers:
... | [
"def",
"clear_message_streams",
"(",
"self",
")",
":",
"for",
"client",
"in",
"self",
".",
"_clients",
":",
"client",
".",
"empty",
"(",
")",
"for",
"server",
"in",
"self",
".",
"_servers",
":",
"server",
".",
"empty",
"(",
")"
] | Resets streams and sockets of incoming messages.
You can use this method to reuse the same connections for several
consecutive test cases. | [
"Resets",
"streams",
"and",
"sockets",
"of",
"incoming",
"messages",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L149-L158 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.new_protocol | def new_protocol(self, protocol_name):
"""Start defining a new protocol template.
All messages sent and received from a connection that uses a protocol
have to conform to this protocol template.
"""
if self._protocol_in_progress:
raise Exception('Can not start a new ... | python | def new_protocol(self, protocol_name):
"""Start defining a new protocol template.
All messages sent and received from a connection that uses a protocol
have to conform to this protocol template.
"""
if self._protocol_in_progress:
raise Exception('Can not start a new ... | [
"def",
"new_protocol",
"(",
"self",
",",
"protocol_name",
")",
":",
"if",
"self",
".",
"_protocol_in_progress",
":",
"raise",
"Exception",
"(",
"'Can not start a new protocol definition in middle of old.'",
")",
"if",
"protocol_name",
"in",
"self",
".",
"_protocols",
... | Start defining a new protocol template.
All messages sent and received from a connection that uses a protocol
have to conform to this protocol template. | [
"Start",
"defining",
"a",
"new",
"protocol",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L160-L171 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.end_protocol | def end_protocol(self):
"""End protocol definition."""
protocol = self._get_message_template()
self._protocols[protocol.name] = protocol
self._protocol_in_progress = False | python | def end_protocol(self):
"""End protocol definition."""
protocol = self._get_message_template()
self._protocols[protocol.name] = protocol
self._protocol_in_progress = False | [
"def",
"end_protocol",
"(",
"self",
")",
":",
"protocol",
"=",
"self",
".",
"_get_message_template",
"(",
")",
"self",
".",
"_protocols",
"[",
"protocol",
".",
"name",
"]",
"=",
"protocol",
"self",
".",
"_protocol_in_progress",
"=",
"False"
] | End protocol definition. | [
"End",
"protocol",
"definition",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L173-L177 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.start_udp_server | def start_udp_server(self, ip, port, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new UDP server to given `ip` and `port`.
Server can be given a `name`, default `timeout` and a `protocol`.
`family` can be either ipv4 (default) or ipv6.
Examples:
| Start U... | python | def start_udp_server(self, ip, port, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new UDP server to given `ip` and `port`.
Server can be given a `name`, default `timeout` and a `protocol`.
`family` can be either ipv4 (default) or ipv6.
Examples:
| Start U... | [
"def",
"start_udp_server",
"(",
"self",
",",
"ip",
",",
"port",
",",
"name",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"protocol",
"=",
"None",
",",
"family",
"=",
"'ipv4'",
")",
":",
"self",
".",
"_start_server",
"(",
"UDPServer",
",",
"ip",
",... | Starts a new UDP server to given `ip` and `port`.
Server can be given a `name`, default `timeout` and a `protocol`.
`family` can be either ipv4 (default) or ipv6.
Examples:
| Start UDP server | 10.10.10.2 | 53 |
| Start UDP server | 10.10.10.2 | 53 | Server1 |
| Start U... | [
"Starts",
"a",
"new",
"UDP",
"server",
"to",
"given",
"ip",
"and",
"port",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L179-L192 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.start_tcp_server | def start_tcp_server(self, ip, port, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new TCP server to given `ip` and `port`.
Server can be given a `name`, default `timeout` and a `protocol`.
`family` can be either ipv4 (default) or ipv6. Notice that you have to
use ... | python | def start_tcp_server(self, ip, port, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new TCP server to given `ip` and `port`.
Server can be given a `name`, default `timeout` and a `protocol`.
`family` can be either ipv4 (default) or ipv6. Notice that you have to
use ... | [
"def",
"start_tcp_server",
"(",
"self",
",",
"ip",
",",
"port",
",",
"name",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"protocol",
"=",
"None",
",",
"family",
"=",
"'ipv4'",
")",
":",
"self",
".",
"_start_server",
"(",
"TCPServer",
",",
"ip",
",... | Starts a new TCP server to given `ip` and `port`.
Server can be given a `name`, default `timeout` and a `protocol`.
`family` can be either ipv4 (default) or ipv6. Notice that you have to
use `Accept Connection` keyword for server to receive connections.
Examples:
| Start TCP se... | [
"Starts",
"a",
"new",
"TCP",
"server",
"to",
"given",
"ip",
"and",
"port",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L194-L208 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.start_sctp_server | def start_sctp_server(self, ip, port, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new STCP server to given `ip` and `port`.
`family` can be either ipv4 (default) or ipv6.
pysctp (https://github.com/philpraxis/pysctp) need to be installed your system.
Server can ... | python | def start_sctp_server(self, ip, port, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new STCP server to given `ip` and `port`.
`family` can be either ipv4 (default) or ipv6.
pysctp (https://github.com/philpraxis/pysctp) need to be installed your system.
Server can ... | [
"def",
"start_sctp_server",
"(",
"self",
",",
"ip",
",",
"port",
",",
"name",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"protocol",
"=",
"None",
",",
"family",
"=",
"'ipv4'",
")",
":",
"self",
".",
"_start_server",
"(",
"SCTPServer",
",",
"ip",
... | Starts a new STCP server to given `ip` and `port`.
`family` can be either ipv4 (default) or ipv6.
pysctp (https://github.com/philpraxis/pysctp) need to be installed your system.
Server can be given a `name`, default `timeout` and a `protocol`.
Notice that you have to use `Accept Connec... | [
"Starts",
"a",
"new",
"STCP",
"server",
"to",
"given",
"ip",
"and",
"port",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L210-L226 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.start_udp_client | def start_udp_client(self, ip=None, port=None, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new UDP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) or ... | python | def start_udp_client(self, ip=None, port=None, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new UDP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) or ... | [
"def",
"start_udp_client",
"(",
"self",
",",
"ip",
"=",
"None",
",",
"port",
"=",
"None",
",",
"name",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"protocol",
"=",
"None",
",",
"family",
"=",
"'ipv4'",
")",
":",
"self",
".",
"_start_client",
"(",
... | Starts a new UDP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) or ipv6.
You should use `Connect` keyword to connect client to a host.
Examples:
| Start UD... | [
"Starts",
"a",
"new",
"UDP",
"client",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L233-L249 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.start_tcp_client | def start_tcp_client(self, ip=None, port=None, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new TCP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) or i... | python | def start_tcp_client(self, ip=None, port=None, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new TCP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) or i... | [
"def",
"start_tcp_client",
"(",
"self",
",",
"ip",
"=",
"None",
",",
"port",
"=",
"None",
",",
"name",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"protocol",
"=",
"None",
",",
"family",
"=",
"'ipv4'",
")",
":",
"self",
".",
"_start_client",
"(",
... | Starts a new TCP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) or ipv6.
You should use `Connect` keyword to connect client to a host.
Examples:
| Start TCP... | [
"Starts",
"a",
"new",
"TCP",
"client",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L251-L267 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.start_sctp_client | def start_sctp_client(self, ip=None, port=None, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new SCTP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) o... | python | def start_sctp_client(self, ip=None, port=None, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new SCTP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) o... | [
"def",
"start_sctp_client",
"(",
"self",
",",
"ip",
"=",
"None",
",",
"port",
"=",
"None",
",",
"name",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"protocol",
"=",
"None",
",",
"family",
"=",
"'ipv4'",
")",
":",
"self",
".",
"_start_client",
"(",... | Starts a new SCTP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) or ipv6.
You should use `Connect` keyword to connect client to a host.
Examples:
| Start T... | [
"Starts",
"a",
"new",
"SCTP",
"client",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L269-L284 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.accept_connection | def accept_connection(self, name=None, alias=None, timeout=0):
"""Accepts a connection to server identified by `name` or the latest
server if `name` is empty.
If given an `alias`, the connection is named and can be later referenced
with that name.
If `timeout` is > 0, the conne... | python | def accept_connection(self, name=None, alias=None, timeout=0):
"""Accepts a connection to server identified by `name` or the latest
server if `name` is empty.
If given an `alias`, the connection is named and can be later referenced
with that name.
If `timeout` is > 0, the conne... | [
"def",
"accept_connection",
"(",
"self",
",",
"name",
"=",
"None",
",",
"alias",
"=",
"None",
",",
"timeout",
"=",
"0",
")",
":",
"server",
"=",
"self",
".",
"_servers",
".",
"get",
"(",
"name",
")",
"server",
".",
"accept_connection",
"(",
"alias",
... | Accepts a connection to server identified by `name` or the latest
server if `name` is empty.
If given an `alias`, the connection is named and can be later referenced
with that name.
If `timeout` is > 0, the connection times out after the time specified.
`timeout` defaults to 0 ... | [
"Accepts",
"a",
"connection",
"to",
"server",
"identified",
"by",
"name",
"or",
"the",
"latest",
"server",
"if",
"name",
"is",
"empty",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L306-L323 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.connect | def connect(self, host, port, name=None):
"""Connects a client to given `host` and `port`. If client `name` is not
given then connects the latest client.
Examples:
| Connect | 127.0.0.1 | 8080 |
| Connect | 127.0.0.1 | 8080 | Client1 |
"""
client = self._clients.... | python | def connect(self, host, port, name=None):
"""Connects a client to given `host` and `port`. If client `name` is not
given then connects the latest client.
Examples:
| Connect | 127.0.0.1 | 8080 |
| Connect | 127.0.0.1 | 8080 | Client1 |
"""
client = self._clients.... | [
"def",
"connect",
"(",
"self",
",",
"host",
",",
"port",
",",
"name",
"=",
"None",
")",
":",
"client",
"=",
"self",
".",
"_clients",
".",
"get",
"(",
"name",
")",
"client",
".",
"connect_to",
"(",
"host",
",",
"port",
")"
] | Connects a client to given `host` and `port`. If client `name` is not
given then connects the latest client.
Examples:
| Connect | 127.0.0.1 | 8080 |
| Connect | 127.0.0.1 | 8080 | Client1 | | [
"Connects",
"a",
"client",
"to",
"given",
"host",
"and",
"port",
".",
"If",
"client",
"name",
"is",
"not",
"given",
"then",
"connects",
"the",
"latest",
"client",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L325-L334 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.server_receives_binary_from | def server_receives_binary_from(self, name=None, timeout=None, connection=None, label=None):
"""Receive raw binary message. Returns message, ip, and port.
If server `name` is not given, uses the latest server. Optional message
`label` is shown on logs.
Examples:
| ${binary} | $... | python | def server_receives_binary_from(self, name=None, timeout=None, connection=None, label=None):
"""Receive raw binary message. Returns message, ip, and port.
If server `name` is not given, uses the latest server. Optional message
`label` is shown on logs.
Examples:
| ${binary} | $... | [
"def",
"server_receives_binary_from",
"(",
"self",
",",
"name",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"connection",
"=",
"None",
",",
"label",
"=",
"None",
")",
":",
"server",
",",
"name",
"=",
"self",
".",
"_servers",
".",
"get_with_name",
"(",... | Receive raw binary message. Returns message, ip, and port.
If server `name` is not given, uses the latest server. Optional message
`label` is shown on logs.
Examples:
| ${binary} | ${ip} | ${port} = | Server receives binary from |
| ${binary} | ${ip} | ${port} = | Server receiv... | [
"Receive",
"raw",
"binary",
"message",
".",
"Returns",
"message",
"ip",
"and",
"port",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L401-L414 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.new_message | def new_message(self, message_name, protocol=None, *parameters):
"""Define a new message template with `message_name`.
`protocol` has to be defined earlier with `Start Protocol Description`.
Optional parameters are default values for message header separated with
colon.
Example... | python | def new_message(self, message_name, protocol=None, *parameters):
"""Define a new message template with `message_name`.
`protocol` has to be defined earlier with `Start Protocol Description`.
Optional parameters are default values for message header separated with
colon.
Example... | [
"def",
"new_message",
"(",
"self",
",",
"message_name",
",",
"protocol",
"=",
"None",
",",
"*",
"parameters",
")",
":",
"proto",
"=",
"self",
".",
"_get_protocol",
"(",
"protocol",
")",
"if",
"not",
"proto",
":",
"raise",
"Exception",
"(",
"\"Protocol not ... | Define a new message template with `message_name`.
`protocol` has to be defined earlier with `Start Protocol Description`.
Optional parameters are default values for message header separated with
colon.
Examples:
| New message | MyMessage | MyProtocol | header_field:value | | [
"Define",
"a",
"new",
"message",
"template",
"with",
"message_name",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L421-L438 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.save_template | def save_template(self, name, unlocked=False):
"""Save a message template for later use with `Load template`.
If saved template is marked as unlocked, then changes can be made to it
afterwards. By default tempaltes are locked.
Examples:
| Save Template | MyMessage |
| S... | python | def save_template(self, name, unlocked=False):
"""Save a message template for later use with `Load template`.
If saved template is marked as unlocked, then changes can be made to it
afterwards. By default tempaltes are locked.
Examples:
| Save Template | MyMessage |
| S... | [
"def",
"save_template",
"(",
"self",
",",
"name",
",",
"unlocked",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"unlocked",
",",
"basestring",
")",
":",
"unlocked",
"=",
"unlocked",
".",
"lower",
"(",
")",
"!=",
"'false'",
"template",
"=",
"self",
... | Save a message template for later use with `Load template`.
If saved template is marked as unlocked, then changes can be made to it
afterwards. By default tempaltes are locked.
Examples:
| Save Template | MyMessage |
| Save Template | MyOtherMessage | unlocked=True | | [
"Save",
"a",
"message",
"template",
"for",
"later",
"use",
"with",
"Load",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L444-L459 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.load_template | def load_template(self, name, *parameters):
"""Load a message template saved with `Save template`.
Optional parameters are default values for message header separated with
colon.
Examples:
| Load Template | MyMessage | header_field:value |
"""
template, fields, h... | python | def load_template(self, name, *parameters):
"""Load a message template saved with `Save template`.
Optional parameters are default values for message header separated with
colon.
Examples:
| Load Template | MyMessage | header_field:value |
"""
template, fields, h... | [
"def",
"load_template",
"(",
"self",
",",
"name",
",",
"*",
"parameters",
")",
":",
"template",
",",
"fields",
",",
"header_fields",
"=",
"self",
".",
"_set_templates_fields_and_header_fields",
"(",
"name",
",",
"parameters",
")",
"self",
".",
"_init_new_message... | Load a message template saved with `Save template`.
Optional parameters are default values for message header separated with
colon.
Examples:
| Load Template | MyMessage | header_field:value | | [
"Load",
"a",
"message",
"template",
"saved",
"with",
"Save",
"template",
".",
"Optional",
"parameters",
"are",
"default",
"values",
"for",
"message",
"header",
"separated",
"with",
"colon",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L461-L470 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.load_copy_of_template | def load_copy_of_template(self, name, *parameters):
"""Load a copy of message template saved with `Save template` when originally saved values need to be preserved
from test to test.
Optional parameters are default values for message header separated with
colon.
Examples:
... | python | def load_copy_of_template(self, name, *parameters):
"""Load a copy of message template saved with `Save template` when originally saved values need to be preserved
from test to test.
Optional parameters are default values for message header separated with
colon.
Examples:
... | [
"def",
"load_copy_of_template",
"(",
"self",
",",
"name",
",",
"*",
"parameters",
")",
":",
"template",
",",
"fields",
",",
"header_fields",
"=",
"self",
".",
"_set_templates_fields_and_header_fields",
"(",
"name",
",",
"parameters",
")",
"copy_of_template",
"=",
... | Load a copy of message template saved with `Save template` when originally saved values need to be preserved
from test to test.
Optional parameters are default values for message header separated with
colon.
Examples:
| Load Copy Of Template | MyMessage | header_field:value | | [
"Load",
"a",
"copy",
"of",
"message",
"template",
"saved",
"with",
"Save",
"template",
"when",
"originally",
"saved",
"values",
"need",
"to",
"be",
"preserved",
"from",
"test",
"to",
"test",
".",
"Optional",
"parameters",
"are",
"default",
"values",
"for",
"... | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L472-L484 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.get_message | def get_message(self, *parameters):
"""Get encoded message.
* Send Message -keywords are convenience methods, that will call this to
get the message object and then send it. Optional parameters are message
field values separated with colon.
Examples:
| ${msg} = | Get me... | python | def get_message(self, *parameters):
"""Get encoded message.
* Send Message -keywords are convenience methods, that will call this to
get the message object and then send it. Optional parameters are message
field values separated with colon.
Examples:
| ${msg} = | Get me... | [
"def",
"get_message",
"(",
"self",
",",
"*",
"parameters",
")",
":",
"_",
",",
"message_fields",
",",
"header_fields",
"=",
"self",
".",
"_get_parameters_with_defaults",
"(",
"parameters",
")",
"return",
"self",
".",
"_encode_message",
"(",
"message_fields",
","... | Get encoded message.
* Send Message -keywords are convenience methods, that will call this to
get the message object and then send it. Optional parameters are message
field values separated with colon.
Examples:
| ${msg} = | Get message |
| ${msg} = | Get message | fiel... | [
"Get",
"encoded",
"message",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L492-L504 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.validate_message | def validate_message(self, msg, *parameters):
"""Validates given message using template defined with `New Message` and
field values given as optional arguments.
Examples:
| Validate message | ${msg} |
| Validate message | ${msg} | status:0 |
"""
_, message_fields... | python | def validate_message(self, msg, *parameters):
"""Validates given message using template defined with `New Message` and
field values given as optional arguments.
Examples:
| Validate message | ${msg} |
| Validate message | ${msg} | status:0 |
"""
_, message_fields... | [
"def",
"validate_message",
"(",
"self",
",",
"msg",
",",
"*",
"parameters",
")",
":",
"_",
",",
"message_fields",
",",
"header_fields",
"=",
"self",
".",
"_get_parameters_with_defaults",
"(",
"parameters",
")",
"self",
".",
"_validate_message",
"(",
"msg",
","... | Validates given message using template defined with `New Message` and
field values given as optional arguments.
Examples:
| Validate message | ${msg} |
| Validate message | ${msg} | status:0 | | [
"Validates",
"given",
"message",
"using",
"template",
"defined",
"with",
"New",
"Message",
"and",
"field",
"values",
"given",
"as",
"optional",
"arguments",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L637-L646 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.uint | def uint(self, length, name, value=None, align=None):
"""Add an unsigned integer to template.
`length` is given in bytes and `value` is optional. `align` can be used
to align the field to longer byte length.
Examples:
| uint | 2 | foo |
| uint | 2 | foo | 42 |
|... | python | def uint(self, length, name, value=None, align=None):
"""Add an unsigned integer to template.
`length` is given in bytes and `value` is optional. `align` can be used
to align the field to longer byte length.
Examples:
| uint | 2 | foo |
| uint | 2 | foo | 42 |
|... | [
"def",
"uint",
"(",
"self",
",",
"length",
",",
"name",
",",
"value",
"=",
"None",
",",
"align",
"=",
"None",
")",
":",
"self",
".",
"_add_field",
"(",
"UInt",
"(",
"length",
",",
"name",
",",
"value",
",",
"align",
"=",
"align",
")",
")"
] | Add an unsigned integer to template.
`length` is given in bytes and `value` is optional. `align` can be used
to align the field to longer byte length.
Examples:
| uint | 2 | foo |
| uint | 2 | foo | 42 |
| uint | 2 | fourByteFoo | 42 | align=4 | | [
"Add",
"an",
"unsigned",
"integer",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L668-L679 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.int | def int(self, length, name, value=None, align=None):
"""Add an signed integer to template.
`length` is given in bytes and `value` is optional. `align` can be used
to align the field to longer byte length.
Signed integer uses twos-complement with bits numbered in big-endian.
Exa... | python | def int(self, length, name, value=None, align=None):
"""Add an signed integer to template.
`length` is given in bytes and `value` is optional. `align` can be used
to align the field to longer byte length.
Signed integer uses twos-complement with bits numbered in big-endian.
Exa... | [
"def",
"int",
"(",
"self",
",",
"length",
",",
"name",
",",
"value",
"=",
"None",
",",
"align",
"=",
"None",
")",
":",
"self",
".",
"_add_field",
"(",
"Int",
"(",
"length",
",",
"name",
",",
"value",
",",
"align",
"=",
"align",
")",
")"
] | Add an signed integer to template.
`length` is given in bytes and `value` is optional. `align` can be used
to align the field to longer byte length.
Signed integer uses twos-complement with bits numbered in big-endian.
Examples:
| int | 2 | foo |
| int | 2 | foo | 42 |
... | [
"Add",
"an",
"signed",
"integer",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L681-L693 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.chars | def chars(self, length, name, value=None, terminator=None):
"""Add a char array to template.
`length` is given in bytes and can refer to earlier numeric fields in
template. Special value '*' in length means that length is encoded to
length of value and decoded as all available bytes.
... | python | def chars(self, length, name, value=None, terminator=None):
"""Add a char array to template.
`length` is given in bytes and can refer to earlier numeric fields in
template. Special value '*' in length means that length is encoded to
length of value and decoded as all available bytes.
... | [
"def",
"chars",
"(",
"self",
",",
"length",
",",
"name",
",",
"value",
"=",
"None",
",",
"terminator",
"=",
"None",
")",
":",
"self",
".",
"_add_field",
"(",
"Char",
"(",
"length",
",",
"name",
",",
"value",
",",
"terminator",
")",
")"
] | Add a char array to template.
`length` is given in bytes and can refer to earlier numeric fields in
template. Special value '*' in length means that length is encoded to
length of value and decoded as all available bytes.
`value` is optional.
`value` could be either a "String" ... | [
"Add",
"a",
"char",
"array",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L695-L716 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.new_struct | def new_struct(self, type, name, *parameters):
"""Defines a new struct to template.
You must call `End Struct` to end struct definition. `type` is the name
for generic type and `name` is the field name in containing structure.
Possible parameters are values for struct fields separated w... | python | def new_struct(self, type, name, *parameters):
"""Defines a new struct to template.
You must call `End Struct` to end struct definition. `type` is the name
for generic type and `name` is the field name in containing structure.
Possible parameters are values for struct fields separated w... | [
"def",
"new_struct",
"(",
"self",
",",
"type",
",",
"name",
",",
"*",
"parameters",
")",
":",
"configs",
",",
"parameters",
",",
"_",
"=",
"self",
".",
"_get_parameters_with_defaults",
"(",
"parameters",
")",
"self",
".",
"_add_struct_name_to_params",
"(",
"... | Defines a new struct to template.
You must call `End Struct` to end struct definition. `type` is the name
for generic type and `name` is the field name in containing structure.
Possible parameters are values for struct fields separated with colon
and optional struct length defined with ... | [
"Defines",
"a",
"new",
"struct",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L723-L742 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore._new_list | def _new_list(self, size, name):
"""Defines a new list to template of `size` and with `name`.
List type must be given after this keyword by defining one field. Then
the list definition has to be closed using `End List`.
Special value '*' in size means that list will decode values as lo... | python | def _new_list(self, size, name):
"""Defines a new list to template of `size` and with `name`.
List type must be given after this keyword by defining one field. Then
the list definition has to be closed using `End List`.
Special value '*' in size means that list will decode values as lo... | [
"def",
"_new_list",
"(",
"self",
",",
"size",
",",
"name",
")",
":",
"self",
".",
"_message_stack",
".",
"append",
"(",
"ListTemplate",
"(",
"size",
",",
"name",
",",
"self",
".",
"_current_container",
")",
")"
] | Defines a new list to template of `size` and with `name`.
List type must be given after this keyword by defining one field. Then
the list definition has to be closed using `End List`.
Special value '*' in size means that list will decode values as long as
data is available. This free l... | [
"Defines",
"a",
"new",
"list",
"to",
"template",
"of",
"size",
"and",
"with",
"name",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L753-L776 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.