Skip to content

Commit

Permalink
add more parody with asyncio example
Browse files Browse the repository at this point in the history
  • Loading branch information
colanconnon committed Nov 4, 2017
1 parent f5f2ede commit 0459f86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions examples/flask_gevent/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ class RandomType(graphene.ObjectType):

class Subscription(graphene.ObjectType):

count_seconds = graphene.Int()
count_seconds = graphene.Int(up_to=graphene.Int())

random_int = graphene.Field(RandomType)


def resolve_count_seconds(root, info):
return Observable.interval(1000).map(lambda i: "{0}".format(i))
def resolve_count_seconds(root, info, up_to):
return Observable.interval(1000)\
.map(lambda i: "{0}".format(i))\
.take_while(lambda i: int(i) <= up_to)

def resolve_random_int(root, info):
import random
Expand Down
1 change: 1 addition & 0 deletions graphql_ws/gevent_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json

from graphql import format_error, graphql
from graphql.execution.executors.sync import SyncExecutor
from rx import Observer, Observable
from .server import BaseWebSocketSubscriptionServer, ConnectionContext, ConnectionClosedException
from .constants import *
Expand Down

0 comments on commit 0459f86

Please sign in to comment.