# Path: django_eventstream/utils.py
# def add_default_headers(headers):
# 	headers['Cache-Control'] = 'no-cache'
# 	headers['X-Accel-Buffering'] = 'no'
# 	augment_cors_headers(headers)


import copy
import threading
import asyncio
import six
from django.http import HttpResponseBadRequest
from channels.generic.http import AsyncHttpConsumer
from channels.http import AsgiRequest
from channels.db import database_sync_to_async
from .utils import add_default_headers
		from .eventrequest import EventRequest
		from .eventstream import get_events
		from django_grip import GripMiddleware
		from .eventrequest import EventRequest
		from .eventstream import EventPermissionError
		from .utils import sse_error_response
		from .eventstream import EventPermissionError
		from .utils import sse_encode_event, make_id

MAX_PENDING = 10

class Listener(object):
	def __init__(self):
		self.loop = asyncio.get_event_loop()
		self.aevent = asyncio.Event()
		self.user_id = ''
		self.channels = set()
		self.channel_items = {}
		self.overflow = False
		self.error = ''

	def wake_threadsafe(self):
		self.loop.call_soon_threadsafe(self.aevent.set)

class ListenerManager(object):
	def __init__(self):
		self.lock = threading.Lock()
		self.listeners_by_channel = {}

	def add_listener(self, listener):
		self.lock.acquire()
		try:
			for channel in listener.channels:
				clisteners = self.listeners_by_channel.get(channel)

# Path: django_eventstream/utils.py
# def add_default_headers(headers):
# 	headers['Cache-Control'] = 'no-cache'
# 	headers['X-Accel-Buffering'] = 'no'
# 	augment_cors_headers(headers)


# Path: django_eventstream/consumers.py
import copy
import threading
import asyncio
import six
from django.http import HttpResponseBadRequest
from channels.generic.http import AsyncHttpConsumer
from channels.http import AsgiRequest
from channels.db import database_sync_to_async
from .utils import add_default_headers
		from .eventrequest import EventRequest
		from .eventstream import get_events
		from django_grip import GripMiddleware
		from .eventrequest import EventRequest
		from .eventstream import EventPermissionError
		from .utils import sse_error_response
		from .eventstream import EventPermissionError
		from .utils import sse_encode_event, make_id


MAX_PENDING = 10

class Listener(object):
	def __init__(self):
		self.loop = asyncio.get_event_loop()
		self.aevent = asyncio.Event()
		self.user_id = ''
		self.channels = set()
		self.channel_items = {}
		self.overflow = False
		self.error = ''

	def wake_threadsafe(self):
		self.loop.call_soon_threadsafe(self.aevent.set)

class ListenerManager(object):
	def __init__(self):
		self.lock = threading.Lock()
		self.listeners_by_channel = {}

	def add_listener(self, listener):
		self.lock.acquire()
		try:
			for channel in listener.channels:
				clisteners = self.listeners_by_channel.get(channel)

				if clisteners is None: