Call for horrible (or nice) models.py files

2009-02-21 Thread Andrew Godwin
Hello everyone, I'm currently working on the next version of South [http://south.aeracode.org], and I need some test fodder for our new models.py parser - rather than our previous approach using regexes and a reasonable amount of hope, this time it's being done properly, using the python parsing

Re: Call for horrible (or nice) models.py files

2009-02-21 Thread Andrew Godwin
Heh, as I expected. So, when I first started on South, I initially tried introspecting the various fields to drag their parameters out of wherever they had been saved to - for example, max_length in a field goes to self.max_length. Then, you have the special cases for Django core fields. For exa

Re: Call for horrible (or nice) models.py files

2009-02-21 Thread Andrew Godwin
ooks nicer at the end, to boot. Andrew Alex Gaynor wrote: > > > On Sat, Feb 21, 2009 at 5:48 PM, Andrew Godwin <mailto:and...@aeracode.org>> wrote: > > > Heh, as I expected. > > So, when I first started on South, I initially tried introspecting the > va

Re: Django/South/MySQL bug

2012-10-31 Thread Andrew Godwin
Hmm, I'm not sure why issuing a query previously isn't fixing it - South just uses the same database cursors that the rest of Django uses, it's one of the few things we don't mess around with. Surely Django has to have some code to deal with the case when there isn't that attribute already? Have y

Re: A migration in one app that adds a field to another

2014-11-04 Thread Andrew Godwin
Carl is right that this isn't a supported thing; Django models are designed to be static, and not mutate based on settings. Migrations are designed to only support one linear change history of models; swappable models are just about supported but not perfect and leads to issues. Adding in the a

Re: Receive Websocket Message from extern task

2017-10-23 Thread Andrew Godwin
I'm not sure what you mean by "receive websockets from an external Python task" - if you want to connect out to your server using a WebSocket from Python, there are libraries that do that. Andrew On Mon, Oct 23, 2017 at 7:40 AM, 'matrix1900' via Django users < django-users@googlegroups.com> wrote

Re: How to start and stopp threads in Django/Channels while using websockets

2017-10-27 Thread Andrew Godwin
You can't do this from inside Django right now - the background workers were designed to solve this problem. Andrew On Fri, Oct 27, 2017 at 6:26 AM, 'matrix1900' via Django users < django-users@googlegroups.com> wrote: > Hi , > > > in my project, I want to use Django and Web sockets. The Solutio

Re: Would it be feasible or an overkill to use channels for real time notification in a Django application.

2017-11-19 Thread Andrew Godwin
You can indeed use Channels as the backbone of a notifications system using WebSockets, but you'll need to overlay your own state logic on top (notably, "what has already been sent to the client?") You can also in theory use Channels 1 to do long-polling, but this is likely going to make a lot more

Re: How to use channels and make a site highly available?

2017-11-21 Thread Andrew Godwin
Right now Sentinel is the only Redis way, we have it set to a few seconds' timeout for failover at work I believe. We can't give a magical solution as any zero-downtime solution ends up being very project-specific; you'll need to build on top of Channels to make your own one if you absolutely need

Re: Django Channels and multi-tenant will this be a world of hurt?

2017-11-24 Thread Andrew Godwin
Your assumptions all seem correct. Also consider that the security model of WebSockets is... interesting, so securing a multi-tenant setup is going to require a bit more work than you would merely doing the same for HTTP requests. There are other non-Channels options around if you want to look int

Re: Django Channels and multi-tenant will this be a world of hurt?

2017-11-26 Thread Andrew Godwin
gt; On Friday, November 24, 2017 at 7:10:29 PM UTC-5, Andrew Godwin wrote: >> >> Your assumptions all seem correct. Also consider that the security model >> of WebSockets is... interesting, so securing a multi-tenant setup is going >> to require a bit more work than you

Re: Django Channels and multi-tenant will this be a world of hurt?

2017-11-27 Thread Andrew Godwin
in you > can't establish the Postgres schema, without the schema you have no tenant > :-) > > Please confirm this would be the approach or whether I am wrong-headed > here. > Thanks. > > On Sunday, November 26, 2017 at 9:58:58 AM UTC-5, Andrew Godwin wrote: >> &

Re: Getting channels 2 to work

2017-12-01 Thread Andrew Godwin
Hi John, It's not in an end-user-useable state quite yet, so apologies for it being hard to install. Crucially, the docs on ASGI_APPLICATION aren't written yet as I'm still working on authentication stuff! A brief guide is: - Make an asgi.py as specified in http://channels.readthedocs.io/en/2.0

Re: Getting channels 2 to work

2017-12-04 Thread Andrew Godwin
g you posted this snippet > > application = ProtocolTypeRouter({ > "http": URLRouter([ > url("^", DjangoViewSystem), > ]), > > But how should the DjangoViewSystem class look like? There is no such file > included. > > > John > > On

Re: Django Channel Error

2017-12-07 Thread Andrew Godwin
That error means you are not actually running a websocket-capable server. Did you add "channels" to INSTALLED_APPS? Andrew On Thu, Dec 7, 2017 at 12:03 AM, Maitreya Verma wrote: > I am following this tutorial > to > learn django

Re: Channels: starting Daphne in production

2017-12-12 Thread Andrew Godwin
Hm, that looks to be like logging from asgi_rabbitmq - could you post your settings configuration? And have you tried running with a different channel layer? Andrew On Tue, Dec 12, 2017 at 10:14 AM, Filbert wrote: > Trying to come up with the proper command line to start Daphne in > production.

Re: Django Channels: Model Binding not sending out message to group

2017-12-13 Thread Andrew Godwin
Since you double-posted, I will reply to the other thread. On Wed, Dec 13, 2017 at 12:00 AM, Zac Kwan wrote: > I have nginx, uwsgi and asgi setup correctly. With my javascript frontend, > it is connected to base on the worker log that contains the demultiplexer > response. However, when I try to

Re: Django Channels Model Binding not sending messages

2017-12-13 Thread Andrew Godwin
That is odd behaviour - have you tried to see if it's actually the group send, or something like trying to send it twice? Can you post your binding configuration? Andrew On Wed, Dec 13, 2017 at 4:14 AM, Zac Kwan wrote: > In production, I have setup asgi, wsgi and nginx. My javascript frontend >

Re: Channels routing - must parse path to separate between consumers?

2017-12-19 Thread Andrew Godwin
What you describe there seems like a bug - the first include() should be adding path restrictions. What's confusing is that you said _both_ consumers are getting called? As in each event goes to two routing entries? That definitely shouldn't happen. Andrew On Tue, Dec 19, 2017 at 4:07 AM, SK wro

Re: Channels routing - must parse path to separate between consumers?

2017-12-20 Thread Andrew Godwin
g > to look as before and send you some details for debugging. I could swear > the same setup as above was giving both or only one of the consumers > working, but never either as it should. > > > > On Tuesday, December 19, 2017 at 8:24:59 PM UTC+2, Andrew Godwin wrote: >>

Re: Asynchoronous programming and websockets support

2018-01-11 Thread Andrew Godwin
Channels is not (at least in the short term) planned to be merged into the Django core, but it is an official Django project. Whether it gets merged in or not in the long term is a much bigger question and one I don't think it's quite mature enough for yet (though Channels 2 may go a long way towar

Re: Asynchoronous programming and websockets support

2018-01-12 Thread Andrew Godwin
I read, he feels (and I agree) that updating a > package version is much easier than updating a language version, and allows > more frequent releases. > > Is this similar to your thinking as well? > > Jason > > On Friday, January 12, 2018 at 1:19:37 AM UTC-5, Andrew Godwin wrote:

Re: [django-channels] post-process message from Group

2018-01-17 Thread Andrew Godwin
Hi Tom, In Channels 1, because of the way Groups work you cannot do post-processing. The only fix for this is a complete rearchitecture which is underway in Channels 2, where you get the ability to act on group messages before they get sent back to the consumer. Channels 2 is not yet ready for pr

Re: Django-Channels: Answer from Background task to channel (websocket)

2018-01-28 Thread Andrew Godwin
It sounds like you're doing the right thing - storing reply channel names and sending to them from a background process - so I think the problem must be in the channel layer configuration. Have you confirmed the background task has the same Django settings? Have you tried monitoring the redis serv

Re: Django-Channels: Debugging

2018-01-29 Thread Andrew Godwin
I'm not sure why the print messages were buffered - next time try flushing stdout and see if that makes it work. Andrew On Mon, Jan 29, 2018 at 6:49 AM, 'Matthias Brück' via Django users < django-users@googlegroups.com> wrote: > Ok, i found the problem, the authentification is not working becaus

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
Hi Ahmed, In the new release channel layers are optional - if you don't configure them they will indeed come through as None. The settings format changed slightly too - you can read more here: http://channels.readthedocs.io/en/latest/topics/channel_layers.html Andrew On Fri, Feb 2, 2018 at 3:31

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
File >> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py", >> line 93, in dispatch >> handler(message) >> File "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\ >> channels\generic\websocket.py", lin

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
It needs to contain a value to work - what value were you trying that was not empty? Andrew On Fri, Feb 2, 2018 at 8:04 PM, Ahmed Magdy wrote: > I tried not having CHANNEL_LAYERS or setting it to {} > same exception > > On Saturday, February 3, 2018 at 3:36:43 AM UTC+2, Andrew

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
empty? I > didn't try setting a value, because only redis was available in v2.0.0 and > I don't like using stuff I don't understand. > > On Saturday, February 3, 2018 at 6:08:02 AM UTC+2, Andrew Godwin wrote: >> >> It needs to contain a value to work - w

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
't the docs mention that though? > > On Saturday, February 3, 2018 at 6:47:47 AM UTC+2, Andrew Godwin wrote: >> >> No, there is no in-memory channel layer any more, only Redis is available >> at the moment. You must put something into the settings in order to make it >

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
>> self.connect() >> File "D:\Programming\DjangoWebsite\HUWebsite\husite\ >> djangoChannels\djangoChannels\consumers.py", line 7, in connect >> AsyncToSync(self.channel_layer.group_add)("chat", self.channel_name) >> File >> "

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
-packages\channels_redis\core.py", >> line 187, in receive_single >> pool = await self.connection(index) >> File >> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels_redis\core.py", >> line 377, in connection >> self.pools[index

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
Ah, yes, it looks like aioredis requires at least 3.5.2. I will update the channels_redis readme to make this clear. On Fri, Feb 2, 2018 at 11:44 PM, Ahmed Magdy wrote: > v3.5.1:37a07cee5969 > > On Saturday, February 3, 2018 at 9:41:38 AM UTC+2, Andrew Godwin wrote: >> >&

Re: Channels with django signals

2018-02-03 Thread Andrew Godwin
Hi John, This is fixed in the asgiref master branch, I should be releasing it soon. Andrew On Sat, Feb 3, 2018 at 4:14 PM, John Wayne wrote: > Hi everyone, > > I am trying to send a channels message from a django signal. The problem > ist that the signal function is not async. So I tried to us

Re: Channels v2.0 - 'RedisChannelLayer' object has no attribute 'ChannelFull'

2018-02-04 Thread Andrew Godwin
Hi, Sorry about this, it was a bug in the group_send method. It's been fixed in channels_redis version 2.0.2. Andrew On Sun, Feb 4, 2018 at 4:19 AM, Ahmed Magdy wrote: > Sending 10~12 messages to the websocket raises an exception > > 'RedisChannelLayer' object has no attribute 'ChannelFull' >>

Re: Channels websocket disconnecting after ~1min

2018-02-04 Thread Andrew Godwin
Hi there, This is a bug that should be fixed in the latest release of Daphne that I put out a few hours ago. Andrew On Sun, Feb 4, 2018 at 3:49 PM, Ahmed Magdy wrote: > Hello, and sorry for lots of questions about channels. > > I can connect to the websocket from JavaScript and send/receive no

Re: Channels websocket disconnecting after ~1min

2018-02-04 Thread Andrew Godwin
That would be me trying to move deployment to Travis. I'll push it up now. Andrew On Sun, Feb 4, 2018 at 5:47 PM, Ahmed Magdy wrote: > Thanks! > > I don't know if it was on purpose but you forgot to update the pypi > package. > > On Monday, February 5, 2018 at 1:5

Re: django-channels 2.0 websocket connection problem (error 500)

2018-02-05 Thread Andrew Godwin
Have you upgraded to the most recent version of Daphne? There was a bug where tracebacks weren't printing sometimes that I fixed over the weekend. Andrew On Mon, Feb 5, 2018 at 9:21 AM, Alberto Buratti < alberthohenstau...@gmail.com> wrote: > Hello, > I've just installed django-channels 2 and fo

Re: channels v2.0.0 disconnect function not triggering

2018-02-06 Thread Andrew Godwin
You are not using it incorrectly - this is a known issue: https://github.com/django/daphne/issues/152 Andrew On Mon, Feb 5, 2018 at 11:53 PM, Ahmed Magdy wrote: > It seems like I cannot get the disconnect function in the consumer to get > called at all. > > class ChatConsumer(WebsocketConsumer)

Re: django-channels-2.0 Postgresql Heroku : Operational Error - 'FATAL too many connections for role “usename”'

2018-02-06 Thread Andrew Godwin
This is an open issue in Channels 2, see here: https://github.com/django/channels/issues/871 Andrew On Tue, Feb 6, 2018 at 5:37 AM, Tomiwa Ademidun wrote: > I am running a web application using Django and Django Rest Framework on > Heroku with a postgresql and redis datastore. I am on the free

Re: Testing Channels database data missing in Consumer

2018-02-06 Thread Andrew Godwin
I'm not quite sure either. Does the test setup work if you are not in async mode? Andrew On Tue, Feb 6, 2018 at 9:45 AM, Daniel Gilge wrote: > Hi, > > this question is related to Channels 2.0, Django 2.0, pytest 3.4, > pytest-django 3.1 and pytest-asyncio 0.8. > > I created a pytest: > > @pytes

Re: Django Postgresql Heroku : Operational Error - 'FATAL too many connections for role “usename”'

2018-02-06 Thread Andrew Godwin
This is a known issue: https://github.com/django/channels/issues/871 Andrew On Tue, Feb 6, 2018 at 5:30 AM, Tomiwa Ademidun wrote: > > 0down votefavorite > > > I am runnin

Re: Testing Channels database data missing in Consumer

2018-02-07 Thread Andrew Godwin
y I ran my development server and did some tests in the browser > console. There it works. I'll continue coding using this technique to > "test" my code and try to find a solution for the other (real) tests as I > have time. > > Am Mittwoch, 7. Februar 2018 04:31:14 UTC+1 s

Re: Channels 2.0 WebSocket demultiplexing

2018-02-07 Thread Andrew Godwin
Hi, It's not yet been re-implemented - here's the issue to track it: https://github.com/django/channels/issues/825 Andrew On Wed, Feb 7, 2018 at 1:53 AM, Daniel Gilge wrote: > Hi, > > how do you demultiplex in Channels 2.0 using WebSockets? > > I want to use a single WebSocket connection and b

Re: Testing Channels 2.0 consumers - problem with routing

2018-02-07 Thread Andrew Godwin
I'm not going to address the mocking, as there's subtle details there (e.g. you mocked group_name as a non-property, I think), but look at the main issue. Can you make your code print out what _is_ in `self.scope`? url_route should definitely be in there, but I am curious what it looks like if it

Re: Testing Channels 2.0 consumers - problem with routing

2018-02-09 Thread Andrew Godwin
> cb=[Future.set_result()]> > > > > P.S. I have a couple more problems with testing this particular project > related to channels. For example I tried ignoring this disconnect problem, > this test passed with 99% coverage, but when I run the whole test suite it > breaks

Re: Testing Channels 2.0 consumers - problem with routing

2018-02-11 Thread Andrew Godwin
ome/khazidhea/.local/share/virtualenvs/django_root- > FXsg3jFU/lib/python3.6/site-packages/aioredis/connection.py:175> > wait_for= 0x7f19b9b6bbe8>()]> cb=[Future.set_result()]> > > > > > But when I run both (I think specifically when B is run after A) I get a > huge

Re: How many live websocket connection can django channels handle?

2018-02-13 Thread Andrew Godwin
What it can handle depends on your setup. If you're using Channels 1, there's potential bottlenecking in the Redis channel layer. Channels 2 is much easier to scale and you can just add more servers as your load demands. I would suggest reducing your websocket load, but it's your call which is mor

Re: Django Channels 2 Group_send to channel layer causes runtime error: "got Future attached to a different loop"

2018-02-16 Thread Andrew Godwin
Can you update your versions of `asgiref` and `channels_redis` please? I fixed those bugs a couple of days ago. Andrew On Fri, Feb 16, 2018 at 10:48 AM, Luke Hebert wrote: > Trying to call the "alert_receive" consumer method > > import json > from channels.consumer import SyncConsumer > from ch

Re: Handle changing users (e.g. a logout) in a scope/WebSockets

2018-02-18 Thread Andrew Godwin
Correct, it's fixed at connection time, much like a Django request object. If you want to vary what user it is, I suggest you just reconnect the websocket when the user logs in or out to make sure you don't have stale data - you should be building for reconnection anyway as network environments wil

Re: [django-channels] Running multiple daphne servers

2018-02-19 Thread Andrew Godwin
Presuming you are using Channels/Daphne 1, then the channel layer configuration is what determines what handles the requests. If you're seeing environments answer each other's requests, check they really are using different Redis databases, and consider changing the prefix setting on the channel l

Re: Channels worker and call_later

2018-02-23 Thread Andrew Godwin
Hi Ken, You should write asyncio code, rather than Twisted code - we have Twisted running on it asyncio reactor so both are available, and asyncio is the only thing you're guaranteed from the spec/other future servers. Given that, I would recommend making a separate asyncio Task that has an "awai

Re: Channels 2.0 - Exception when sending a message to client

2018-02-24 Thread Andrew Godwin
You are entirely right, Ken - the problem here is that "self.send()" on consumers where their scope type is "channel" is not defined. I suspect we could do with a better error message in this case rather than the one shown here. The confusion probably comes as this would sort have worked in Channe

Re: [django-channels] Testing events from post_save signal

2018-02-25 Thread Andrew Godwin
I think the change you need to make is swapping in database_sync_to_async rather than sync_to_async - see here: http://channels.readthedocs.io/en/latest/topics/databases.html Andrew On Sun, Feb 25, 2018 at 7:14 AM, Tomáš Ehrlich wrote: > Here's the gist (https://gist.github.com/tricoder42/ > af

Re: [django-channels] Testing events from post_save signal

2018-02-25 Thread Andrew Godwin
>Tom > > 25. 2. 2018 v 19:12, Andrew Godwin : > > I think the change you need to make is swapping in database_sync_to_async > rather than sync_to_async - see here: http://channels. > readthedocs.io/en/latest/topics/databases.html > > Andrew > > On Sun, Feb 25, 2018

Re: Disconnect WS on server shutdown

2018-02-26 Thread Andrew Godwin
At the moment there is not - you should follow this issue: https://github.com/django/daphne/issues/177 On Mon, Feb 26, 2018 at 9:37 AM, Igor Partola wrote: > I am running into an issue with one of my applications that is running on > Heroku. Basically during a deploy, the old daphne process gets

Re: Channels 1.x

2018-02-27 Thread Andrew Godwin
Yes, there is one session made per connection. They should expire and get cleaned up like normal HTTP sessions if you run the session cleanup in Django (or use backends that auto-cleanup) Andrew On Tue, Feb 27, 2018 at 11:00 AM, nferrari wrote: > Hello, > > I'm using django-channels for some mo

Re: django-channels: WebSocketBridge options

2018-02-28 Thread Andrew Godwin
Hi Nicolas, It's likely just an oversight in the coding. We're actually in the process of removing official support for that JavaScript code as we have nobody to maintain it, so I suggest you either clone it and modify it yourself or use ReconnectingWebSocket directly. Andrew On Wed, Feb 28, 201

Re: Channels: channel_layer appears to time out

2018-03-01 Thread Andrew Godwin
Hi Toby, Do you have the latest versions of daphne, channels, asgiref and channels_redis? This sounds supiciously like a bug I fixed a couple weeks ago. Andrew On Thu, Mar 1, 2018 at 5:45 AM, wrote: > Hello, > > I have a project that uses Channels as a worker queue, with a SyncConsumer > that

Re: Channels 2: Consumer running twice when two users simultaneously share socket

2018-03-01 Thread Andrew Godwin
Can you clarify what you mean by "two users connected to the same socket"? If you have two websockets connected, you'll have two copies of your consumer running, one for each socket. Andrew On Thu, Mar 1, 2018 at 7:52 AM, lakeshow wrote: > I am running into an issue using Channels where if two

Re: Channels 2: Consumer running twice when two users simultaneously share socket

2018-03-01 Thread Andrew Godwin
daphne==2.0.4 > > I'm realizing now that I've a lot of left-over installs since upgrading > from Channels 1.x. I'm no longer even sure which I need. Could this be the > issue? > > > On Friday, March 2, 2018 at 6:49:41 AM UTC+9, Andrew Godwin wrote: >> >&

Re: Django Channels AuthMiddleware question

2018-03-03 Thread Andrew Godwin
Hi Hugo, The AuthMiddleware, like its Django counterpart, does not query the auth backend immediately - it is lazily done the first time you access the scope["user"] object. This does present a risk that you could access it during an async method body, though - I will look into how we could fix th

Re: Django Channels AuthMiddleware question

2018-03-04 Thread Andrew Godwin
> Regarding the SessionMiddleware wouldn't this be part a more general > problem with routers? As it is they currently have to be async "safe". > > > On Sunday, March 4, 2018 at 3:03:05 AM UTC, Andrew Godwin wrote: >> >> Hi Hugo, >> >> The Aut

Re: How do I transmit any changes to databases(i.e. creates and updates pertaining to a particular user) using Django Channels?

2018-03-08 Thread Andrew Godwin
Hi Alexis, You'll need to do some work yourself - hook into database changes (either via signals or overriding the save method) to send change notifications to a different Group for each user (maybe use group names like "user-123213", where the number is their ID). Then, when someone connects via

Re: Printing to console from async method inside django channels

2018-03-09 Thread Andrew Godwin
Hi Chris, Since you also posted this to GitHub ( https://github.com/django/channels/issues/967), I will answer there. Andrew On Thu, Mar 8, 2018 at 8:17 PM, Chris Barry wrote: > I'm trying to print inside these methods in from this example in django > channels: > > https://github.com/andrewgod

Re: Listening to a django channel from outside a consumer

2018-03-13 Thread Andrew Godwin
Hi Alex, Consumers aren't designed to be run outside of a Channels or ASGI environment. If you read the ASGI spec ( https://github.com/django/asgiref/blob/master/specs/asgi.rst), you'll see that to run a consumer - which is an ASGI app - you need to do quite a bit more than you did there, in parti

Re: separate http requests between channels routing and "classic django routing

2018-03-13 Thread Andrew Godwin
You can just use channels.http.AsgiHandler as the consumer/ASGI app to hand off to Django views. It's mentioned in the last paragraph here: http://channels.readthedocs.io/en/latest/topics/routing.html#protocoltyperouter Andrew On Tue, Mar 13, 2018 at 9:20 AM, Kevin Tewouda wrote: > Hello, > i a

Re: separate http requests between channels routing and "classic django routing

2018-03-14 Thread Andrew Godwin
, > re_path(r'', AsgiHandler) > ] > > > I think there should be a warning in the tutorial to take particular > attention with the *path* method introduced in django 2. > > Thanks again. > > Le mercredi 14 mars 2018 05:19:28 UTC+1, Andrew Godwin a écrit : >

Re: Is anyone using Channels 2 and asgi_rabbitmq?

2018-03-19 Thread Andrew Godwin
Hi Filbery, asgi_rabbitmq has not been ported to work with the new asynchronous channel layer API in Channels 2 yet, so it's not compatible, I'm afraid, and nobody is currently working on that port as far as I know. Andrew On Mon, Mar 19, 2018 at 8:13 AM, Filbert wrote: > Making a major platfo

Re: Django 2.0 and AsgiRequest Error

2018-03-20 Thread Andrew Godwin
Hi - did you also open this issue on GitHub: https://github.com/django/channels/issues/981 ? In either case, your MIDDLEWARE setting would be useful, this looks like a middleware is not running. Andrew On Tue, Mar 20, 2018 at 2:47 PM, G Broten wrote: > Django Users: > I've done a Google searc

Re: Overriding channel-layer's group_send and group_add to add persistence

2018-03-23 Thread Andrew Godwin
It looks correct at first glance - I would insert a debugger there and see what the Redis database contained manually at that point. Andrew On Fri, Mar 23, 2018 at 2:56 AM, 'Alex' via Django users < django-users@googlegroups.com> wrote: > I've been trying to add persistence to channel layers, su

Re: channels and middlewares

2018-03-23 Thread Andrew Godwin
Check your Django version - MIDDLEWARE_CLASSES is deprecated, you should be using the new MIDDLEWARE setting. Andrew On Fri, Mar 23, 2018 at 8:56 AM, Matteo Lucchesi wrote: > It' possible that running a django application with channel2 ingores my > MIDDLEWARE_CLASSES over HTTP? > > -- > You rec

Re: Overriding channel-layer's group_send and group_add to add persistence

2018-03-23 Thread Andrew Godwin
e. One thing I'm certain of is that it's in redis! > > Alex > > On Friday, 23 March 2018 15:58:37 UTC, Andrew Godwin wrote: >> >> It looks correct at first glance - I would insert a debugger there and >> see what the Redis database contained manually a

Re: Django channels 2 and data binding

2018-03-24 Thread Andrew Godwin
There are no examples yet - I removed data binding from core Channels in the 2.0 release because it had a high maintenance overhead and as yet there's not a replacement. I was hoping someone might volunteer to help build it as an external package but if not, I may eventually get time to write it la

Re: Django channels 2 and data binding

2018-03-25 Thread Andrew Godwin
You can write most of the data binding functionality yourself in Channels 2 by adding group send methods to model save methods, but if Channels 1 is working for you right now, I wouldn't move until you're forced to. Andrew On Sat, Mar 24, 2018 at 11:07 PM, Fabio Andrés García Sánchez < fabio.garc

Re: Django Channels 2 poor performance and high CPU usage

2018-03-26 Thread Andrew Godwin
(You double-posted this so I'm just going to reply to this one) I need to know a bit more information about what the slowdown is - in particular: * Have you run with PYTHONASYNCIODEBUG=1 set as an environment variable to check for non-yielding coroutines? * What sort of messages per second are we

Re: Django Channels 2 poor performance and high CPU usage

2018-03-27 Thread Andrew Godwin
y backend for >> the memory layer, none of my websocket connections get past HANDSHAKING so >> I'm not exactly sure whats up there. >> >> On Monday, 26 March 2018 17:35:34 UTC+1, Andrew Godwin wrote: >>> >>> (You double-posted this so I'm just going to r

Re: Does Daphne of Django Channels send out a heartbeat to keep the connection alive?

2018-03-29 Thread Andrew Godwin
The underlying Daphne code will send PING requests to the client periodically, adjustable with --ping-interval. If it doesn't get a response back before --ping-timeout, it will close the connection. Heroku have their own loadbalancer, so it's possible that is changing how the sockets behave. Andr

Re: Getting channels 2 to work

2018-03-30 Thread Andrew Godwin
2.02) and Python(3.5.1) within a > virtual environment. I also installed asgi_redis. > > -Luke > > On Monday, December 4, 2017 at 11:11:14 AM UTC-6, Andrew Godwin wrote: >> >> Hi John, >> >> The ProtocolTypeRouter currently does this for you automatically as long >&

Re: [django-channels] Which process sends message to all channels in a group during group_send?

2018-03-30 Thread Andrew Godwin
When you do a group send, the message doing the sending fans out the send to all the target channels (currently using individual commands, and soon with a Lua script inside Redis). We're not using redis pub-sub - we use lists instead. Andrew On Fri, Mar 30, 2018 at 2:26 AM, krdeepak wrote: > Hi

Re: Channels 2.0 max number of connections

2018-04-04 Thread Andrew Godwin
It depends on your server and how busy the connections are. If you need more you should run more instances of Daphne. Andrew On Wed, 4 Apr 2018, 05:21 Алексей Кузуб, wrote: > Hello! How many connections Channels 2.0 can handle and keep open > simultaneously? And how should I configure Daphne th

Re: Channels 2.0 max number of connections

2018-04-04 Thread Andrew Godwin
No, there is no hard limit programmed into Daphne. It will keep accepting as long as it can. Andrew On Wed, Apr 4, 2018 at 11:30 PM, Алексей Кузуб wrote: > But no limit in params or in some other place? > > среда, 4 апреля 2018 г., 20:00:11 UTC+3 пользователь Andrew Godwin написал:

Re: Mysql is gone away auth middleware channels 2

2018-04-05 Thread Andrew Godwin
You must do all database access through a synchronous function wrapped in database_sync_to_async - you can't just call it directly on an asyncio thread: http://channels.readthedocs.io/en/latest/topics/databases.html#database-sync-to-async Andrew On Thu, Apr 5, 2018 at 5:25 AM, Matteo Lucchesi wr

Re: Using channels, how to send a notification to single user by model changed trigger event?

2018-04-07 Thread Andrew Godwin
Make a Group per user, and then send to that group. You should treat a user as a group as they may have multiple windows or tabs open. Andrew On Sat, Apr 7, 2018 at 7:02 AM, wrote: > This example showed > in django project how to use channels

Re: wrong imports channel ?

2018-04-12 Thread Andrew Godwin
Channels 2 has different objects and import paths - code from Channels 1 (like you have there) isn't compatible. Andrew On Thu, Apr 12, 2018 at 12:37 AM, Jules LE BRIS wrote: > Hi, > > I would like to do something like this in views.py : > > message = {"message":msg} > Channel('chat').send(mess

Re: Django Channels also works when I have no Worker running.

2018-04-17 Thread Andrew Godwin
Channels 2 does not run requests in workers. Workers are now only for running background tasks on specific channels, and so you do not need them normally. Andrew On Tue, Apr 17, 2018 at 6:54 AM, Christopher Wittlinger < cwittlinge...@gmail.com> wrote: > I think I misunderstood the concept of the

Re: Architecting a Crypto Market Data Feed using Django Channels

2018-04-28 Thread Andrew Godwin
I can't help you with real-time streaming architecture overall - that's a much bigger scope of thing - but I can say that you shouldn't be keeping a synchronous consumer open like that (you're using a whole thread). You should either rewrite it to be async-native, so it doesn't use up a thread and

Re: Channels 2: Consumer lifecycle when run in a worker process

2018-05-02 Thread Andrew Godwin
- Will `MyConsumer` receive new `wakeup` messages while awaiting ` some_process`? Yes. The worker server runs as many application instances as there are messages coming in, even though they all have the same scope. You can see the main listening loop here: https://github.com/django/channels/

Re: Channels 2: Consumer lifecycle when run in a worker process

2018-05-02 Thread Andrew Godwin
s one gets free again. Can you give me a clue how to achieve this > bevaviour? > > > среда, 2 мая 2018 г., 18:39:01 UTC+3 пользователь Andrew Godwin написал: >> >> >>- Will `MyConsumer` receive new `wakeup` messages while awaiting ` >>some_process`? >> &

Re: Channels 2: Consumer lifecycle when run in a worker process

2018-05-02 Thread Andrew Godwin
w to achieve this... sorry for bothering, but probably you > have some bright idea, please? > > Anyway, thank you for explanation you have already gave me, it helps, and > it is always pleasure to chat with you :-) > > среда, 2 мая 2018 г., 22:35:08 UTC+3 пользователь Andrew Godw

Re: Django-channels request depending Middleware

2018-05-04 Thread Andrew Godwin
That's correct - Django middleware only runs on HTTP request objects, and so doesn't work in a WebSocket context. The recommended alternative is to write ASGI middleware for this purpose. Unfortunately, there is not good documentation on this yet, but you can see a bit about it here, in the authen

Re: Django Channels client not consuming

2018-05-15 Thread Andrew Godwin
Hi, I'm afraid you're using incredibly old versions of Channels and the bugs you're encountering are almost certainly fixed in more recent releases. I'm not sure there's much I can do. Andrew On Tue, 15 May 2018, 13:01 LEEPS Lab, wrote: > We have an issue implementing django channels in an oTr

Re: Django channels with python background tasks

2018-05-26 Thread Andrew Godwin
Hi Jaiswal, I'm afraid that I can't give detailed help about what your best options are or walk you through how to do it - that's something you'll have to research and decide on yourself. Channels allows you to do low-latency communictation between Django back-ends and JavaScript, but anything you

Re: How to test a WebsocketConsumer that has async_to_sync code in it

2018-06-06 Thread Andrew Godwin
Hi - I will reply on the ticket, as I'll be requesting you paste a large chunk of code and the formatting is better over there! Andrew On Wed, Jun 6, 2018 at 12:26 PM 'Artemis' via Django users < django-users@googlegroups.com> wrote: > I cannot test my *WebsocketConsumer* ( which includes many *

Re: Django Channels

2016-10-16 Thread Andrew Godwin
Hi Amirtpal, a) You would use WebSockets for this purpose. I can't give a summary of how they work here - there's plenty of documentation out there about them - but they tunnel over HTTP(S) and provide bidirectional communication. b) If the firewall is just limiting ports, then yes. If there's

Re: How to handle Video/Audio streaming using Django Channels?

2016-11-04 Thread Andrew Godwin
Hi Sandro, Could you highlight what the problems you're facing are? Channels is not particularly designed for streaming large files - you're better doing that using a CDN or dedicated file streaming software - so I'd be curious to know what the particular issues you're facing are. Andrew On Fri,

Re: How to handle Video/Audio streaming using Django Channels?

2016-11-04 Thread Andrew Godwin
s even possibile? > > Thanks again! > > *Sandro Salles* > e-mail. san...@snippet.com.br > telefone. (11) 99203-9014 (cel/whatsapp) > > > On Fri, Nov 4, 2016 at 2:49 PM, Andrew Godwin wrote: > >> Hi Sandro, >> >> Could you highlight what the problems you&#

Re: Running daphne in production - Mac OS X Server 10.11

2016-11-10 Thread Andrew Godwin
Hi Adam, It looks like you're running the main site through mod_wsgi, which means that it does not support WebSockets; daphne won't help as you're running it on a different port. Either you need to access the whole site via Daphne, or change the code so that it appends a different port to the WebS

Re: Running daphne in production - Mac OS X Server 10.11

2016-11-10 Thread Andrew Godwin
p the server itself so that > Daphne is doing all the work - or perhaps I am missing something completely > obvious here. > > Thanks again Andrew! > > Adam > > > On Thursday, 10 November 2016 17:33:32 UTC-3, Andrew Godwin wrote: >> >> Hi Adam, >> >&

Re: Running daphne in production - Mac OS X Server 10.11

2016-11-11 Thread Andrew Godwin
That's not the problem - if an incoming connection is a WebSocket it does not run through the URL resolver (as you are seeing there) but instead gets upgraded on the wire and dispatched differently. A quick read up makes it seem like the Apache proxy module does not understand WebSocket (it's a bi

  1   2   3   4   >