File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -128,15 +128,22 @@ def change_subscription(self, topics):
128
128
129
129
Raises:
130
130
IllegalStateErrror: if assign_from_user has been used already
131
+ TypeError: if a non-str topic is given
131
132
"""
132
133
if self ._user_assignment :
133
134
raise IllegalStateError (self ._SUBSCRIPTION_EXCEPTION_MESSAGE )
134
135
136
+ if isinstance (topics , str ):
137
+ topics = [topics ]
138
+
135
139
if self .subscription == set (topics ):
136
140
log .warning ("subscription unchanged by change_subscription(%s)" ,
137
141
topics )
138
142
return
139
143
144
+ if any (not isinstance (t , str ) for t in topics ):
145
+ raise TypeError ('All topics must be strings' )
146
+
140
147
log .info ('Updating subscribed topics to: %s' , topics )
141
148
self .subscription = set (topics )
142
149
self ._group_subscription .update (topics )
You can’t perform that action at this time.
0 commit comments