|
33 | 33 | import plugins.sqs |
34 | 34 |
|
35 | 35 | # Some consts |
36 | | -PUBSUB_VERSION = '0.6.3' |
| 36 | +PUBSUB_VERSION = '0.7.0' |
37 | 37 | PUBSUB_CONTENT_TYPE = 'application/vnd.pypubsub-stream' |
38 | 38 | PUBSUB_DEFAULT_PORT = 2069 |
39 | 39 | PUBSUB_DEFAULT_IP = '0.0.0.0' |
@@ -302,7 +302,10 @@ def __init__(self, server, connection, request): |
302 | 302 | self.lock = asyncio.Lock() |
303 | 303 |
|
304 | 304 | # Set topics subscribed to |
305 | | - self.topics = [x for x in request.path.split('/') if x] |
| 305 | + self.topics = [] |
| 306 | + for topic_batch in request.path.split(','): |
| 307 | + sub_to = [x for x in topic_batch.split('/') if x] |
| 308 | + self.topics.append(sub_to) |
306 | 309 |
|
307 | 310 | # Is the client old and expecting zero-terminators? |
308 | 311 | self.old_school = False |
@@ -393,16 +396,18 @@ async def publish(self, subscribers): |
393 | 396 | if not can_see: |
394 | 397 | continue |
395 | 398 | # If subscribed to all the topics, tell a subscriber about this |
396 | | - if all(el in self.topics for el in sub.topics): |
397 | | - try: |
398 | | - if sub.old_school: |
399 | | - async with sub.lock: |
400 | | - await asyncio.wait_for(sub.connection.write(ojs), timeout=PUBSUB_WRITE_TIMEOUT) |
401 | | - else: |
402 | | - async with sub.lock: |
403 | | - await asyncio.wait_for(sub.connection.write(js), timeout=PUBSUB_WRITE_TIMEOUT) |
404 | | - except Exception: |
405 | | - bad_subs.append(sub) |
| 399 | + for topic_batch in sub.topics: |
| 400 | + if all(el in self.topics for el in topic_batch): |
| 401 | + try: |
| 402 | + if sub.old_school: |
| 403 | + async with sub.lock: |
| 404 | + await asyncio.wait_for(sub.connection.write(ojs), timeout=PUBSUB_WRITE_TIMEOUT) |
| 405 | + else: |
| 406 | + async with sub.lock: |
| 407 | + await asyncio.wait_for(sub.connection.write(js), timeout=PUBSUB_WRITE_TIMEOUT) |
| 408 | + except Exception: |
| 409 | + bad_subs.append(sub) |
| 410 | + break |
406 | 411 | return bad_subs |
407 | 412 |
|
408 | 413 |
|
|
0 commit comments