You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was chasing down two issues yesterday due to member name clashes. Turns out I was overriding AsyncConsumer.channel_name and RedisChannelLayer.connection (something I will add in another ticket in channels_redis if this ticket is deemed appropriate). AsyncConsumer.channel_name's purpose isn't particularly clear since it acts like more of a unique ID used for registration than a singular name, but I would have avoided the issue if I followed the tutorial more closely. The RedisChannelLayer.connection override, though, exposes the problem more directly. There are a number of member variables that need to be left alone for any of the functionality to work such as InMemoryChannelLayer.groups and InMemoryChannelLayer.channels, both of which might be really easy to overwrite without diving into the source and understanding how everything works under the covers.
I suggest using the following pattern across most of the classes meant to be used as base classes:
I used InMemoryChannelLayer since it was the most direct example of the use of these variables since the others ended up defining member variables within functions, such as AsyncConsumer.channel_name (which is a more appropriate example) being defined within AsyncConsumer.__call__ (also not ideal).
This pattern should help others avoid the problems I ran into in the future and help maintain the functionality of this library. The following, for example, should fail:
I was chasing down two issues yesterday due to member name clashes. Turns out I was overriding
AsyncConsumer.channel_name
andRedisChannelLayer.connection
(something I will add in another ticket inchannels_redis
if this ticket is deemed appropriate).AsyncConsumer.channel_name
's purpose isn't particularly clear since it acts like more of a unique ID used for registration than a singular name, but I would have avoided the issue if I followed the tutorial more closely. TheRedisChannelLayer.connection
override, though, exposes the problem more directly. There are a number of member variables that need to be left alone for any of the functionality to work such asInMemoryChannelLayer.groups
andInMemoryChannelLayer.channels
, both of which might be really easy to overwrite without diving into the source and understanding how everything works under the covers.I suggest using the following pattern across most of the classes meant to be used as base classes:
I used
InMemoryChannelLayer
since it was the most direct example of the use of these variables since the others ended up defining member variables within functions, such asAsyncConsumer.channel_name
(which is a more appropriate example) being defined withinAsyncConsumer.__call__
(also not ideal).This pattern should help others avoid the problems I ran into in the future and help maintain the functionality of this library. The following, for example, should fail:
That redefinition should result in the following error:
The text was updated successfully, but these errors were encountered: