Skip to content

Instantly share code, notes, and snippets.

@gaffer-93
gaffer-93 / helloworld_keepalive_deadlines.py
Last active November 6, 2018 20:53
gRPC's helloworld example modified to demonstrate deadlines and keepalive TCP_USER_TIMEOUT introduced in 1.16
import grpc
import time
import helloworld_pb2
import helloworld_pb2_grpc
def run():
channel_opts = [
(
# Interval at which grpc will send keepalive pings
'grpc.keepalive_time_ms',
@gaffer-93
gaffer-93 / grpc_lptrace.py
Created October 30, 2018 18:31
lptrace output tracing RPC call and subsequent blocking within _channel.py
python
_call_ (/opt/venvs/service/local/lib/python2.7/site-packages/grpc/_channel.py:489)
_blocking (/opt/venvs/service/local/lib/python2.7/site-packages/grpc/_channel.py:470)_prepare (/opt/venvs/service/local/lib/python2.7/site-packages/grpc/_channel.py:453)
_start_unary_request (/opt/venvs/service/local/lib/python2.7/site-packages/grpc/_channel.py:419)
_deadline (/opt/venvs/service/local/lib/python2.7/site-packages/grpc/_channel.py:55)
serialize (/opt/venvs/service/local/lib/python2.7/site-packages/grpc/_common.py:120)_transform (/opt/venvs/service/local/lib/python2.7/site-packages/grpc/_common.py:109)
_init_ (/opt/venvs/service/local/lib/python2.7/site-packages/grpc/_channel.py:102)
Condition (/usr/lib/python2.7/threading.py:241)
_init_ (/usr/lib/python2.7/threading.py:259)
_init_ (/usr/lib/python2.7/threading.py:58)
# Initial indexed count query
{
filter0(func: eq(tagkey_name, "server")) {
tagkey_value @filter(NOT regexp(tagvalue_name,/web10009.*/)){
C_0 as count(tagvalue_item)
}
sum(val(C_0))
}
filter1(func: eq(tagkey_name, "server")) {
tagkey_value @filter(regexp(tagvalue_name,/web1000.*/)){
def helowordl():
print "Helo Wordl!"
helowordl()
@gaffer-93
gaffer-93 / gist:d8b9d5d392cc20cf3364b42be981f1f9
Created June 27, 2018 09:48
greeter_client.py with timeouts
```
# Copyright 2015 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
// So I think this will work, havent tested it though
void draw()
{
size(500, 500);
// So we want 5 triangles...
int number_of_triangles = 5;
// that get 5 times bigger everytime?
int scaler = 5;
// So I think this will work, havent tested it though
void draw()
{
size(500, 500);
// So we want 5 triangles...
number_of_triangles = 5;
// that get 5 times bigger everytime?
scaler = 5;
void draw()
{
size(500, 500);
x = 0;
y = 0;
w = 10;
h = 10;
for (int i = 5; i <= 45; i = i + 5) {
x = i;
y = y + i * 2;