I am trying to use django channels and asgi to run a simple chat server. I have channels and daphne installed, but when I try to run the development server, I get the following error.
Unhandled exception in thread started by <function wrapper at 0x1062fdc80>
Traceback (most recent call last):
File "/Users/yash/code/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Users/yash/code/lib/python2.7/site-packages/channels/management/commands/runserver.py", line 63, in inner_run
"layer": self.channel_layer,
File "/Users/yash/code/lib/python2.7/site-packages/channels/asgi.py", line 86, in __str__
return "%s (%s)" % (self.alias, name_that_thing(self.channel_layer))
File "/Users/yash/code/lib/python2.7/site-packages/channels/utils.py", line 25, in name_that_thing
return name_that_thing(thing.__class__)
File "/Users/yash/code/lib/python2.7/site-packages/channels/utils.py", line 16, in name_that_thing
if hasattr(thing, "__class__") and not isinstance(thing, (types.FunctionType, types.MethodType)):
AttributeError: 'module' object has no attribute 'FunctionType'
I have checked out the last file and found that the error is with the types module. the line import types
worked fine, but when the script trys to call types.FunctionType
it gives an AttributeError. When I imported the script on the shell, It worked as expected
Any help is greatly appreciated. :)
EDIT
print(types)
outputs:
<module 'types' from '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/types.pyc'>
EDIT 2 I started another django project with channels, cloned a repository from github. When I ran the development server after installing dependencies, It worked perfectly. The channels utils file is the exact same, so any help explaining this would help.