django_longpolling
django_longpolling copied to clipboard
Timeout overridden to None in BaseLongPollingView dispatch method
Using Django 1.6.1, and django_longpolling 0.1.1 (installed using pip), it would appear that the timeout value passed to BaseLongPollingView (either through the as_view method or set via derived class) is ignored. It looks like the following line in dispatch is the culprit:
self.timeout = self.kwargs.get('channel')
In my case, kwargs is empty (from Django); if this is standard, then self.timeout should not be set here without checking to make sure there's a value in kwargs to set.
I worked around this by overriding dispatch in my derived class:
def dispatch(self, request, *args, **kwargs):
kwargs['channel'] = self.timeout
return BaseLongPollingView.dispatch(self, request, *args, **kwargs)
This is functional, but sub-optimal. It would be better if BaseLongPollingVIew checked existence of the key in kwargs before accessing it.
Hi,
thanks for pointing this out.
I forgot to cleanup kwargs['channel'] = self.timeout from a previous version, that line is actually doing nothing than confuse the reader.
You should override the timeout subclassing one of the two view class and overriding the timeout attribute (default is 30s)
0.1.2 is available on pip
:thumbsup: