@@ -104,7 +104,7 @@ channel_routing = [
104104```
105105
106106## Publish-Subscribe
107- Includes several publish-subscribe (pubsub) classes for hooking
107+ Included are several publish-subscribe (pubsub) classes for hooking
108108up your mutations to your subscriptions. When a client makes a
109109subscription, the pubsub can be used to map from one subscription name
110110to one or more channel names to subscribe to the right channels.
@@ -127,7 +127,7 @@ from graphql_ws.pubsub import AsyncioPubsub
127127
128128# create a new pubsub object; this class is in-memory and does
129129# not utilze Redis
130- p = AsyncioPubsub()
130+ pubsub = AsyncioPubsub()
131131
132132
133133class MutationExample (graphene .Mutation ):
@@ -138,7 +138,7 @@ class MutationExample(graphene.Mutation):
138138
139139 async def mutate (self , info , input_text ):
140140 # publish to the pubsub object before returning mutation
141- await p .publish(' BASE' , input_text)
141+ await pubsub .publish(' BASE' , input_text)
142142 return MutationExample(output_text = input_text)
143143
144144
@@ -153,14 +153,14 @@ class Subscription(graphene.ObjectType):
153153 try :
154154 # pubsub subscribe_to_channel method returns
155155 # subscription id and an asyncio.Queue
156- sub_id, q = p .subscribe_to_channel(' BASE' )
156+ sub_id, q = pubsub .subscribe_to_channel(' BASE' )
157157 while True :
158158 payload = await q.get()
159159 yield payload
160160 except asyncio.CancelledError:
161161 # unsubscribe subscription id from channel
162162 # when coroutine is cancelled
163- p .unsubscribe(' BASE' , sub_id)
163+ pubsub .unsubscribe(' BASE' , sub_id)
164164
165165schema = graphene.Schema(mutation = Mutations,
166166 subscription = Subscription)
@@ -184,7 +184,7 @@ from rx import Observable
184184
185185# create a new pubsub object; in the case you'll need to
186186# be running a redis-server instance in a separate process
187- p = GeventRxRedisPubsub()
187+ pubsub = GeventRxRedisPubsub()
188188
189189
190190class MutationExample (graphene .Mutation ):
@@ -195,7 +195,7 @@ class MutationExample(graphene.Mutation):
195195
196196 def mutate (self , info , input_text ):
197197 # publish to the pubsub before returning mutation
198- p .publish(' BASE' , input_text)
198+ pubsub .publish(' BASE' , input_text)
199199 return MutationExample(output_text = input_text)
200200
201201
@@ -208,9 +208,9 @@ class Subscription(graphene.ObjectType):
208208
209209 def resolve_mutation_example (root , info ):
210210 # pubsub subscribe_to_channel method returns an observable
211- # when observable is cancelled , the subscription will
211+ # when observable is disposed of , the subscription will
212212 # be cleaned up and unsubscribed from
213- return p .subscribe_to_channel(' BASE' )\
213+ return pubsub .subscribe_to_channel(' BASE' )\
214214 .map(lambda i : " {0} " .format(i))
215215
216216
0 commit comments