fix iterator
This commit is contained in:
+3
-14
@@ -1,6 +1,4 @@
|
||||
import queue
|
||||
import sse
|
||||
import json
|
||||
from exceptions import TooManyConnections
|
||||
|
||||
class Sse(object):
|
||||
@@ -75,13 +73,8 @@ class Sse(object):
|
||||
self._buffer = []
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def __next__(self):
|
||||
print("Next in SSE")
|
||||
print(self._buffer)
|
||||
for item in self._buffer:
|
||||
return item
|
||||
yield item
|
||||
self.flush()
|
||||
|
||||
|
||||
@@ -133,18 +126,14 @@ class SseStream():
|
||||
|
||||
def __iter__(self):
|
||||
print("Iter called")
|
||||
return self
|
||||
|
||||
def __next__(self):
|
||||
""" Method which is called regular to send out the event """
|
||||
print("Next called")
|
||||
print(f'Queue Size: {self._queue.qsize()}')
|
||||
while True:
|
||||
msg = self._queue.get(block=True, timeout=None)
|
||||
if isinstance( msg, Sse ):
|
||||
print("Message: ", msg)
|
||||
for data in msg:
|
||||
print(data)
|
||||
return data.encode('utf-8')
|
||||
yield data.encode('utf-8')
|
||||
|
||||
def addMessage(self, event_name, data, id = 0):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user