Skip to content

Commit 0459f86

Browse files
committed
add more parody with asyncio example
1 parent f5f2ede commit 0459f86

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

examples/flask_gevent/flask_app.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ class RandomType(graphene.ObjectType):
2121

2222
class Subscription(graphene.ObjectType):
2323

24-
count_seconds = graphene.Int()
24+
count_seconds = graphene.Int(up_to=graphene.Int())
2525

2626
random_int = graphene.Field(RandomType)
2727

2828

29-
def resolve_count_seconds(root, info):
30-
return Observable.interval(1000).map(lambda i: "{0}".format(i))
29+
def resolve_count_seconds(root, info, up_to):
30+
return Observable.interval(1000)\
31+
.map(lambda i: "{0}".format(i))\
32+
.take_while(lambda i: int(i) <= up_to)
3133

3234
def resolve_random_int(root, info):
3335
import random

graphql_ws/gevent_server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22

33
from graphql import format_error, graphql
4+
from graphql.execution.executors.sync import SyncExecutor
45
from rx import Observer, Observable
56
from .server import BaseWebSocketSubscriptionServer, ConnectionContext, ConnectionClosedException
67
from .constants import *

0 commit comments

Comments
 (0)