fix iterator
This commit is contained in:
parent
86f0569201
commit
e3c61e2afe
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue