repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/_queue.py#L159-L190
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", "# 2bytes for size", "for", "i", ",", "arg", "in", "enumerate", "(", "self", ".", "args", ")", ":", "if", "space_left", ...
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/messages/call_continue.py#L55-L101
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 none then give empty Response", "if", "mixed", "is", "None", ":", "return", "Response", "(", ")", "# if not Response, then treat like body", "if", "not", "isinstance", "(", "mixed", ",", "Response", ")", ":...
Create Response from mixed input.
[ "Create", "Response", "from", "mixed", "input", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/response.py#L104-L116
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/event.py#L133-L151
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", ")", ":", "# heapify", "n", "=", "h", ".", "size", "(", ")", "for", "i", "in", "six", ".", "moves", ".", "range", "(", "int", "(", "math", ".", "floor", "(", "n", "/", "2", ")", ")", "-", "1", ",", "-", "1", ",", ...
Initialize existing object into the heap.
[ "Initialize", "existing", "object", "into", "the", "heap", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/container/heap.py#L74-L79
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/container/heap.py#L82-L85
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/container/heap.py#L88-L93
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/container/heap.py#L96-L104
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/container/heap.py#L107-L110
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 contains indexes of items yet to be checked.", "items", "=", "deque", "(", "[", "0", "]", ")", "while", "items", ":", "current", "=", "items", "."...
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/container/heap.py#L141-L179
uber/tchannel-python
tchannel/tracing.py
span_to_tracing_field
def span_to_tracing_field(span): """ Inject the span into Trace field, if Zipkin format is supported :param span: OpenTracing Span """ if span is None: return common.random_tracing() # noinspection PyBroadException try: carrier = {} span.tracer.inject(span, ZIPKIN_SPA...
python
def span_to_tracing_field(span): """ Inject the span into Trace field, if Zipkin format is supported :param span: OpenTracing Span """ if span is None: return common.random_tracing() # noinspection PyBroadException try: carrier = {} span.tracer.inject(span, ZIPKIN_SPA...
[ "def", "span_to_tracing_field", "(", "span", ")", ":", "if", "span", "is", "None", ":", "return", "common", ".", "random_tracing", "(", ")", "# noinspection PyBroadException", "try", ":", "carrier", "=", "{", "}", "span", ".", "tracer", ".", "inject", "(", ...
Inject the span into Trace field, if Zipkin format is supported :param span: OpenTracing Span
[ "Inject", "the", "span", "into", "Trace", "field", "if", "Zipkin", "format", "is", "supported", ":", "param", "span", ":", "OpenTracing", "Span" ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tracing.py#L267-L287
uber/tchannel-python
tchannel/tracing.py
apply_trace_flag
def apply_trace_flag(span, trace, default_trace): """ If ``trace`` (or ``default_trace``) is False, disables tracing on ``span``. :param span: :param trace: :param default_trace: :return: """ if trace is None: trace = default_trace trace = trace() if callable(trace) else trac...
python
def apply_trace_flag(span, trace, default_trace): """ If ``trace`` (or ``default_trace``) is False, disables tracing on ``span``. :param span: :param trace: :param default_trace: :return: """ if trace is None: trace = default_trace trace = trace() if callable(trace) else trac...
[ "def", "apply_trace_flag", "(", "span", ",", "trace", ",", "default_trace", ")", ":", "if", "trace", "is", "None", ":", "trace", "=", "default_trace", "trace", "=", "trace", "(", ")", "if", "callable", "(", "trace", ")", "else", "trace", "if", "trace", ...
If ``trace`` (or ``default_trace``) is False, disables tracing on ``span``. :param span: :param trace: :param default_trace: :return:
[ "If", "trace", "(", "or", "default_trace", ")", "is", "False", "disables", "tracing", "on", "span", ".", ":", "param", "span", ":", ":", "param", "trace", ":", ":", "param", "default_trace", ":", ":", "return", ":" ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tracing.py#L290-L302
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", ")", ":", "# noinspection PyBroadException", "try", ":", "# Currently Java does not populate Tracing field, so do not", "# mistaken it for a real trace ID.", "if", "request", ".", "tracing", ".", "trace_id", ":", "contex...
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tracing.py#L111-L135
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", "# noinspection PyBroadException", "try", ":", "if", "headers", "and", "hasattr", "(", "headers", ",", "'iteritems'", ...
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tracing.py#L137-L180
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/errors.py#L84-L99
uber/tchannel-python
crossdock/server/server.py
serve
def serve(): """main entry point""" logging.getLogger().setLevel(logging.DEBUG) logging.info('Python Tornado Crossdock Server Starting ...') tracer = Tracer( service_name='python', reporter=NullReporter(), sampler=ConstSampler(decision=True)) opentracing.tracer = tracer ...
python
def serve(): """main entry point""" logging.getLogger().setLevel(logging.DEBUG) logging.info('Python Tornado Crossdock Server Starting ...') tracer = Tracer( service_name='python', reporter=NullReporter(), sampler=ConstSampler(decision=True)) opentracing.tracer = tracer ...
[ "def", "serve", "(", ")", ":", "logging", ".", "getLogger", "(", ")", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "logging", ".", "info", "(", "'Python Tornado Crossdock Server Starting ...'", ")", "tracer", "=", "Tracer", "(", "service_name", "=", "...
main entry point
[ "main", "entry", "point" ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/crossdock/server/server.py#L23-L43
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/thrift/server.py#L35-L100
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/thrift/server.py#L206-L225
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/thrift/server.py#L227-L248
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tchannel.py#L151-L235
uber/tchannel-python
tchannel/tchannel.py
TChannel.advertise
def advertise(self, routers=None, name=None, timeout=None, router_file=None, jitter=None): """Advertise with Hyperbahn. After a successful advertisement, Hyperbahn will establish long-lived connections with your application. These connections are used to load balance i...
python
def advertise(self, routers=None, name=None, timeout=None, router_file=None, jitter=None): """Advertise with Hyperbahn. After a successful advertisement, Hyperbahn will establish long-lived connections with your application. These connections are used to load balance i...
[ "def", "advertise", "(", "self", ",", "routers", "=", "None", ",", "name", "=", "None", ",", "timeout", "=", "None", ",", "router_file", "=", "None", ",", "jitter", "=", "None", ")", ":", "if", "routers", "is", "not", "None", "and", "router_file", "i...
Advertise with Hyperbahn. After a successful advertisement, Hyperbahn will establish long-lived connections with your application. These connections are used to load balance inbound and outbound requests to other applications on the Hyperbahn network. Re-advertisement happens p...
[ "Advertise", "with", "Hyperbahn", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tchannel.py#L295-L391
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", ")", ":", "# start with a request maker instance", "maker", "=", "ThriftRequestMaker", "(", "service", "=", "service", ",", "t...
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/thrift/module.py#L40-L104
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", "# raise application exception, if present", "for", "exc_spec", "in", "result_spec", "[", "1", ":", "]", ":", "exc", "=", "getattr", "("...
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/thrift/module.py#L209-L240
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/peer_strategy.py#L41-L60
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/singleton.py#L44-L51
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/singleton.py#L54-L59
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/singleton.py#L62-L77
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", ")", "# message_factory will create Request only when it recei...
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" ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/dispatch.py#L89-L117
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/dispatch.py#L291-L329
uber/tchannel-python
tchannel/messages/common.py
random_tracing
def random_tracing(): """ Create new Tracing() tuple with random IDs. """ new_id = _uniq_id() return Tracing( span_id=new_id, parent_id=0, trace_id=new_id, traceflags=0)
python
def random_tracing(): """ Create new Tracing() tuple with random IDs. """ new_id = _uniq_id() return Tracing( span_id=new_id, parent_id=0, trace_id=new_id, traceflags=0)
[ "def", "random_tracing", "(", ")", ":", "new_id", "=", "_uniq_id", "(", ")", "return", "Tracing", "(", "span_id", "=", "new_id", ",", "parent_id", "=", "0", ",", "trace_id", "=", "new_id", ",", "traceflags", "=", "0", ")" ]
Create new Tracing() tuple with random IDs.
[ "Create", "new", "Tracing", "()", "tuple", "with", "random", "IDs", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/messages/common.py#L76-L85
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/messages/common.py#L138-L153
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/messages/common.py#L156-L177
uber/tchannel-python
tchannel/tornado/hyperbahn.py
advertise
def advertise(tchannel, service, routers=None, timeout=None, router_file=None, jitter=None): """Advertise with Hyperbahn. See :py:class:`tchannel.TChannel.advertise`. """ timeout = timeout or FIRST_ADVERTISE_TIME if routers is not None and router_file is not None: raise ValueE...
python
def advertise(tchannel, service, routers=None, timeout=None, router_file=None, jitter=None): """Advertise with Hyperbahn. See :py:class:`tchannel.TChannel.advertise`. """ timeout = timeout or FIRST_ADVERTISE_TIME if routers is not None and router_file is not None: raise ValueE...
[ "def", "advertise", "(", "tchannel", ",", "service", ",", "routers", "=", "None", ",", "timeout", "=", "None", ",", "router_file", "=", "None", ",", "jitter", "=", "None", ")", ":", "timeout", "=", "timeout", "or", "FIRST_ADVERTISE_TIME", "if", "routers", ...
Advertise with Hyperbahn. See :py:class:`tchannel.TChannel.advertise`.
[ "Advertise", "with", "Hyperbahn", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/hyperbahn.py#L157-L184
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/hyperbahn.py#L81-L94
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/hyperbahn.py#L102-L121
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tombstone.py#L83-L97
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tombstone.py#L103-L108
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/response.py#L109-L119
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/response.py#L122-L133
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/response.py#L135-L151
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/response.py#L153-L170
uber/tchannel-python
tchannel/tornado/response.py
Response.write_header
def write_header(self, chunk): """Write to header. Note: the header stream is only available to write before write body. :param chunk: content to write to header :except TChannelError: Raise TChannelError if the response's flush() has been called """ if se...
python
def write_header(self, chunk): """Write to header. Note: the header stream is only available to write before write body. :param chunk: content to write to header :except TChannelError: Raise TChannelError if the response's flush() has been called """ if se...
[ "def", "write_header", "(", "self", ",", "chunk", ")", ":", "if", "self", ".", "serializer", ":", "header", "=", "self", ".", "serializer", ".", "serialize_header", "(", "chunk", ")", "else", ":", "header", "=", "chunk", "if", "self", ".", "flushed", "...
Write to header. Note: the header stream is only available to write before write body. :param chunk: content to write to header :except TChannelError: Raise TChannelError if the response's flush() has been called
[ "Write", "to", "header", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/response.py#L172-L195
uber/tchannel-python
tchannel/tornado/response.py
Response.write_body
def write_body(self, chunk): """Write to header. Note: whenever write_body is called, the header stream will be closed. write_header method is unavailable. :param chunk: content to write to body :except TChannelError: Raise TChannelError if the response's flush() h...
python
def write_body(self, chunk): """Write to header. Note: whenever write_body is called, the header stream will be closed. write_header method is unavailable. :param chunk: content to write to body :except TChannelError: Raise TChannelError if the response's flush() h...
[ "def", "write_body", "(", "self", ",", "chunk", ")", ":", "if", "self", ".", "serializer", ":", "body", "=", "self", ".", "serializer", ".", "serialize_body", "(", "chunk", ")", "else", ":", "body", "=", "chunk", "if", "self", ".", "flushed", ":", "r...
Write to header. Note: whenever write_body is called, the header stream will be closed. write_header method is unavailable. :param chunk: content to write to body :except TChannelError: Raise TChannelError if the response's flush() has been called
[ "Write", "to", "header", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/response.py#L197-L224
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L905-L956
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L156-L168
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L278-L300
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L302-L318
uber/tchannel-python
tchannel/tornado/connection.py
TornadoConnection._write_fragments
def _write_fragments(self, fragments): """ :param fragments: A generator of messages """ answer = tornado.gen.Future() if not fragments: answer.set_result(None) return answer io_loop = IOLoop.current() def _write_fragment(fut...
python
def _write_fragments(self, fragments): """ :param fragments: A generator of messages """ answer = tornado.gen.Future() if not fragments: answer.set_result(None) return answer io_loop = IOLoop.current() def _write_fragment(fut...
[ "def", "_write_fragments", "(", "self", ",", "fragments", ")", ":", "answer", "=", "tornado", ".", "gen", ".", "Future", "(", ")", "if", "not", "fragments", ":", "answer", ".", "set_result", "(", "None", ")", "return", "answer", "io_loop", "=", "IOLoop",...
:param fragments: A generator of messages
[ ":", "param", "fragments", ":", "A", "generator", "of", "messages" ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L320-L345
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L359-L402
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L405-L431
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L452-L501
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L504-L522
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L524-L543
uber/tchannel-python
tchannel/tornado/connection.py
StreamConnection._stream
def _stream(self, context, message_factory): """write request/response into frames Transform request/response into protocol level message objects based on types and argstreams. Assumption: the chunk data read from stream can fit into memory. If arg stream is at init or streami...
python
def _stream(self, context, message_factory): """write request/response into frames Transform request/response into protocol level message objects based on types and argstreams. Assumption: the chunk data read from stream can fit into memory. If arg stream is at init or streami...
[ "def", "_stream", "(", "self", ",", "context", ",", "message_factory", ")", ":", "args", "=", "[", "]", "try", ":", "for", "argstream", "in", "context", ".", "argstreams", ":", "chunk", "=", "yield", "argstream", ".", "read", "(", ")", "args", ".", "...
write request/response into frames Transform request/response into protocol level message objects based on types and argstreams. Assumption: the chunk data read from stream can fit into memory. If arg stream is at init or streaming state, build the message based on current chu...
[ "write", "request", "/", "response", "into", "frames" ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L579-L628
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" ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L646-L657
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L659-L693
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L713-L724
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L777-L799
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L850-L858
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tchannel.py#L189-L232
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", ")", ":", "# TODO disallow certain parameters or don't propagate them backwards.", "# Fo...
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tchannel.py#L262-L296
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tchannel.py#L298-L350
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tchannel.py#L368-L387
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", "# Imported inside the function so that we don't have a hard dependency", "# on the Thrift library. This fu...
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tchannel.py#L389-L409
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/tchannel.py#L411-L477
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/peer_heap.py#L63-L78
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" ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/peer_heap.py#L111-L116
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" ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/peer_heap.py#L118-L123
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", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/peer_heap.py#L136-L147
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", "." ]
train
https://github.com/zamzterz/Flask-pyoidc/blob/0dba3ce8931fe5e039c66d7d645331bdbb52960a/src/flask_pyoidc/pyoidc_facade.py#L100-L140
zamzterz/Flask-pyoidc
src/flask_pyoidc/pyoidc_facade.py
PyoidcFacade.userinfo_request
def userinfo_request(self, access_token): """ Args: access_token (str): Bearer access token to use when fetching userinfo Returns: oic.oic.message.OpenIDSchema: UserInfo Response """ http_method = self._provider_configuration.userinfo_endpoint_method ...
python
def userinfo_request(self, access_token): """ Args: access_token (str): Bearer access token to use when fetching userinfo Returns: oic.oic.message.OpenIDSchema: UserInfo Response """ http_method = self._provider_configuration.userinfo_endpoint_method ...
[ "def", "userinfo_request", "(", "self", ",", "access_token", ")", ":", "http_method", "=", "self", ".", "_provider_configuration", ".", "userinfo_endpoint_method", "if", "http_method", "is", "None", "or", "not", "self", ".", "_client", ".", "userinfo_endpoint", ":...
Args: access_token (str): Bearer access token to use when fetching userinfo Returns: oic.oic.message.OpenIDSchema: UserInfo Response
[ "Args", ":", "access_token", "(", "str", ")", ":", "Bearer", "access", "token", "to", "use", "when", "fetching", "userinfo" ]
train
https://github.com/zamzterz/Flask-pyoidc/blob/0dba3ce8931fe5e039c66d7d645331bdbb52960a/src/flask_pyoidc/pyoidc_facade.py#L142-L158
zamzterz/Flask-pyoidc
src/flask_pyoidc/user_session.py
UserSession.update
def update(self, access_token=None, id_token=None, id_token_jwt=None, userinfo=None): """ Args: access_token (str) id_token (Mapping[str, str]) id_token_jwt (str) userinfo (Mapping[str, str]) """ def set_if_defined(session_key, value): ...
python
def update(self, access_token=None, id_token=None, id_token_jwt=None, userinfo=None): """ Args: access_token (str) id_token (Mapping[str, str]) id_token_jwt (str) userinfo (Mapping[str, str]) """ def set_if_defined(session_key, value): ...
[ "def", "update", "(", "self", ",", "access_token", "=", "None", ",", "id_token", "=", "None", ",", "id_token_jwt", "=", "None", ",", "userinfo", "=", "None", ")", ":", "def", "set_if_defined", "(", "session_key", ",", "value", ")", ":", "if", "value", ...
Args: access_token (str) id_token (Mapping[str, str]) id_token_jwt (str) userinfo (Mapping[str, str])
[ "Args", ":", "access_token", "(", "str", ")", "id_token", "(", "Mapping", "[", "str", "str", "]", ")", "id_token_jwt", "(", "str", ")", "userinfo", "(", "Mapping", "[", "str", "str", "]", ")" ]
train
https://github.com/zamzterz/Flask-pyoidc/blob/0dba3ce8931fe5e039c66d7d645331bdbb52960a/src/flask_pyoidc/user_session.py#L45-L66
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/robotbackgroundlogger.py#L59-L71
robotframework/Rammbock
src/Rammbock/decorator.py
decorate
def decorate(func, caller): """ decorate(func, caller) decorates a function using a caller. """ evaldict = func.__globals__.copy() evaldict['_call_'] = caller evaldict['_func_'] = func fun = FunctionMaker.create( func, "return _call_(_func_, %(shortsignature)s)", evaldict, __...
python
def decorate(func, caller): """ decorate(func, caller) decorates a function using a caller. """ evaldict = func.__globals__.copy() evaldict['_call_'] = caller evaldict['_func_'] = func fun = FunctionMaker.create( func, "return _call_(_func_, %(shortsignature)s)", evaldict, __...
[ "def", "decorate", "(", "func", ",", "caller", ")", ":", "evaldict", "=", "func", ".", "__globals__", ".", "copy", "(", ")", "evaldict", "[", "'_call_'", "]", "=", "caller", "evaldict", "[", "'_func_'", "]", "=", "func", "fun", "=", "FunctionMaker", "....
decorate(func, caller) decorates a function using a caller.
[ "decorate", "(", "func", "caller", ")", "decorates", "a", "function", "using", "a", "caller", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/decorator.py#L224-L236
robotframework/Rammbock
src/Rammbock/decorator.py
decorator
def decorator(caller, _func=None): """decorator(caller) converts a caller function into a decorator""" if _func is not None: # return a decorated function # this is obsolete behavior; you should use decorate instead return decorate(_func, caller) # else return a decorator function if in...
python
def decorator(caller, _func=None): """decorator(caller) converts a caller function into a decorator""" if _func is not None: # return a decorated function # this is obsolete behavior; you should use decorate instead return decorate(_func, caller) # else return a decorator function if in...
[ "def", "decorator", "(", "caller", ",", "_func", "=", "None", ")", ":", "if", "_func", "is", "not", "None", ":", "# return a decorated function", "# this is obsolete behavior; you should use decorate instead", "return", "decorate", "(", "_func", ",", "caller", ")", ...
decorator(caller) converts a caller function into a decorator
[ "decorator", "(", "caller", ")", "converts", "a", "caller", "function", "into", "a", "decorator" ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/decorator.py#L239-L271
robotframework/Rammbock
src/Rammbock/core.py
RammbockCore.set_client_handler
def set_client_handler(self, handler_func, name=None, header_filter=None, interval=0.5): """Sets an automatic handler for the type of message template currently loaded. This feature allows users to set a python handler function which is called automatically by the Rammbock message queue when me...
python
def set_client_handler(self, handler_func, name=None, header_filter=None, interval=0.5): """Sets an automatic handler for the type of message template currently loaded. This feature allows users to set a python handler function which is called automatically by the Rammbock message queue when me...
[ "def", "set_client_handler", "(", "self", ",", "handler_func", ",", "name", "=", "None", ",", "header_filter", "=", "None", ",", "interval", "=", "0.5", ")", ":", "msg_template", "=", "self", ".", "_get_message_template", "(", ")", "client", ",", "client_nam...
Sets an automatic handler for the type of message template currently loaded. This feature allows users to set a python handler function which is called automatically by the Rammbock message queue when message matches the expected template. The optional name argument defines the client node to w...
[ "Sets", "an", "automatic", "handler", "for", "the", "type", "of", "message", "template", "currently", "loaded", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L63-L96
robotframework/Rammbock
src/Rammbock/core.py
RammbockCore.set_server_handler
def set_server_handler(self, handler_func, name=None, header_filter=None, alias=None, interval=0.5): """Sets an automatic handler for the type of message template currently loaded. This feature allows users to set a python handler function which is called automatically by the Rammbock message q...
python
def set_server_handler(self, handler_func, name=None, header_filter=None, alias=None, interval=0.5): """Sets an automatic handler for the type of message template currently loaded. This feature allows users to set a python handler function which is called automatically by the Rammbock message q...
[ "def", "set_server_handler", "(", "self", ",", "handler_func", ",", "name", "=", "None", ",", "header_filter", "=", "None", ",", "alias", "=", "None", ",", "interval", "=", "0.5", ")", ":", "msg_template", "=", "self", ".", "_get_message_template", "(", ")...
Sets an automatic handler for the type of message template currently loaded. This feature allows users to set a python handler function which is called automatically by the Rammbock message queue when message matches the expected template. The optional name argument defines the server node to w...
[ "Sets", "an", "automatic", "handler", "for", "the", "type", "of", "message", "template", "currently", "loaded", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L98-L134
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L136-L147
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L149-L158
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L160-L171
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L173-L177
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L179-L192
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L194-L208
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L210-L226
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L233-L249
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L251-L267
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L269-L284
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L306-L323
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L325-L334
robotframework/Rammbock
src/Rammbock/core.py
RammbockCore.client_sends_binary
def client_sends_binary(self, message, name=None, label=None): """Send raw binary `message`. If client `name` is not given, uses the latest client. Optional message `label` is shown on logs. Examples: | Client sends binary | Hello! | | Client sends binary | ${some binar...
python
def client_sends_binary(self, message, name=None, label=None): """Send raw binary `message`. If client `name` is not given, uses the latest client. Optional message `label` is shown on logs. Examples: | Client sends binary | Hello! | | Client sends binary | ${some binar...
[ "def", "client_sends_binary", "(", "self", ",", "message", ",", "name", "=", "None", ",", "label", "=", "None", ")", ":", "client", ",", "name", "=", "self", ".", "_clients", ".", "get_with_name", "(", "name", ")", "client", ".", "send", "(", "message"...
Send raw binary `message`. If client `name` is not given, uses the latest client. Optional message `label` is shown on logs. Examples: | Client sends binary | Hello! | | Client sends binary | ${some binary} | Client1 | label=DebugMessage |
[ "Send", "raw", "binary", "message", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L344-L356
robotframework/Rammbock
src/Rammbock/core.py
RammbockCore.server_sends_binary
def server_sends_binary(self, message, name=None, connection=None, label=None): """Send raw binary `message`. If server `name` is not given, uses the latest server. Optional message `label` is shown on logs. Examples: | Server sends binary | Hello! | | Server sends bina...
python
def server_sends_binary(self, message, name=None, connection=None, label=None): """Send raw binary `message`. If server `name` is not given, uses the latest server. Optional message `label` is shown on logs. Examples: | Server sends binary | Hello! | | Server sends bina...
[ "def", "server_sends_binary", "(", "self", ",", "message", ",", "name", "=", "None", ",", "connection", "=", "None", ",", "label", "=", "None", ")", ":", "server", ",", "name", "=", "self", ".", "_servers", ".", "get_with_name", "(", "name", ")", "serv...
Send raw binary `message`. If server `name` is not given, uses the latest server. Optional message `label` is shown on logs. Examples: | Server sends binary | Hello! | | Server sends binary | ${some binary} | Server1 | label=DebugMessage | | Server sends binary | ${some...
[ "Send", "raw", "binary", "message", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L359-L372
robotframework/Rammbock
src/Rammbock/core.py
RammbockCore.client_receives_binary
def client_receives_binary(self, name=None, timeout=None, label=None): """Receive raw binary message. If client `name` is not given, uses the latest client. Optional message `label` is shown on logs. Examples: | ${binary} = | Client receives binary | | ${binary} = | Cli...
python
def client_receives_binary(self, name=None, timeout=None, label=None): """Receive raw binary message. If client `name` is not given, uses the latest client. Optional message `label` is shown on logs. Examples: | ${binary} = | Client receives binary | | ${binary} = | Cli...
[ "def", "client_receives_binary", "(", "self", ",", "name", "=", "None", ",", "timeout", "=", "None", ",", "label", "=", "None", ")", ":", "client", ",", "name", "=", "self", ".", "_clients", ".", "get_with_name", "(", "name", ")", "msg", "=", "client",...
Receive raw binary message. If client `name` is not given, uses the latest client. Optional message `label` is shown on logs. Examples: | ${binary} = | Client receives binary | | ${binary} = | Client receives binary | Client1 | timeout=5 |
[ "Receive", "raw", "binary", "message", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L374-L387
robotframework/Rammbock
src/Rammbock/core.py
RammbockCore.server_receives_binary
def server_receives_binary(self, name=None, timeout=None, connection=None, label=None): """Receive raw binary message. If server `name` is not given, uses the latest server. Optional message `label` is shown on logs. Examples: | ${binary} = | Server receives binary | | ...
python
def server_receives_binary(self, name=None, timeout=None, connection=None, label=None): """Receive raw binary message. If server `name` is not given, uses the latest server. Optional message `label` is shown on logs. Examples: | ${binary} = | Server receives binary | | ...
[ "def", "server_receives_binary", "(", "self", ",", "name", "=", "None", ",", "timeout", "=", "None", ",", "connection", "=", "None", ",", "label", "=", "None", ")", ":", "return", "self", ".", "server_receives_binary_from", "(", "name", ",", "timeout", ","...
Receive raw binary message. If server `name` is not given, uses the latest server. Optional message `label` is shown on logs. Examples: | ${binary} = | Server receives binary | | ${binary} = | Server receives binary | Server1 | connection=my_connection | timeout=5 |
[ "Receive", "raw", "binary", "message", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L389-L399
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L401-L414
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L421-L438
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L444-L459
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L461-L470
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", "...
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L472-L484
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", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L492-L504
robotframework/Rammbock
src/Rammbock/core.py
RammbockCore.client_receives_message
def client_receives_message(self, *parameters): """Receive a message with template defined using `New Message` and validate field values. Message template has to be defined with `New Message` before calling this. Optional parameters: - `name` the client name (default is...
python
def client_receives_message(self, *parameters): """Receive a message with template defined using `New Message` and validate field values. Message template has to be defined with `New Message` before calling this. Optional parameters: - `name` the client name (default is...
[ "def", "client_receives_message", "(", "self", ",", "*", "parameters", ")", ":", "with", "self", ".", "_receive", "(", "self", ".", "_clients", ",", "*", "parameters", ")", "as", "(", "msg", ",", "message_fields", ",", "header_fields", ")", ":", "self", ...
Receive a message with template defined using `New Message` and validate field values. Message template has to be defined with `New Message` before calling this. Optional parameters: - `name` the client name (default is the latest used) example: `name=Client 1` - `timeo...
[ "Receive", "a", "message", "with", "template", "defined", "using", "New", "Message", "and", "validate", "field", "values", "." ]
train
https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L551-L571