Re: Async Help Needed

2021-08-12 Thread Andrew Godwin
The example you presented should Just Work - that error generally only occurs if you return an un-awaited coroutine, which if you're just returning a response, should be impossible. What version of Python and Django are you running? Andrew On Thu, Aug 12, 2021, at 11:03 AM, Steven Mapes wrote:

Re: register_converter doesn't work with ASGI

2021-06-20 Thread Andrew Godwin
Ah yes, that's because the URL parsing/conversion all happens in the main (async, in ASGI mode) thread - and because to_python is a a synchronous function interface, there is literally nothing you can do to make it work. The only real way of fixing this would be for Django to patch the URL conv

Re: Daphne raises Internal Server Error when accessing static files from development server

2021-04-06 Thread Andrew Godwin
500 Internal Server Error > Transfer-Encoding: chunked > Content-Type: text/html; charset=utf-8 > > Dana utorak, 6. travnja 2021. u 18:26:34 UTC+2 korisnik Andrew Godwin napisao > je: >> __ >> The tracebacks are there somewhere, you might have to look at the raw HTTP >

Re: Daphne raises Internal Server Error when accessing static files from development server

2021-04-06 Thread Andrew Godwin
t; > HTTP GET /static/css/style.css 500 [0.35, 127.0.0.1:37982] > HTTP GET /static/js/jquery-2.2.4.min.js 500 [0.35, 127.0.0.1:37988] > > Dana utorak, 6. travnja 2021. u 18:09:33 UTC+2 korisnik Andrew Godwin napisao > je: >> __ >> Aha, glad to hear it! My apologies that

Re: Daphne raises Internal Server Error when accessing static files from development server

2021-04-06 Thread Andrew Godwin
ot;django 3.2 requires >> asgiref<4,>=3.3.2, but you have asgiref 3.3.1 which is incompatible."), but >> static files are served well. >> >> I tried with the very last version 3.3.3 (-e >> git+https://github.com/django/asgiref.git#egg=asgiref), but problem

Re: Daphne raises Internal Server Error when accessing static files from development server

2021-04-06 Thread Andrew Godwin
ef<4,>=3.3.2, but you have asgiref 3.3.1 which is incompatible."), but > static files are served well. > > I tried with the very last version 3.3.3 (-e > git+https://github.com/django/asgiref.git#egg=asgiref), but problem hasn't > been fixed that way. > >

Re: Daphne raises Internal Server Error when accessing static files from development server

2021-04-06 Thread Andrew Godwin
This may be related to https://github.com/django/asgiref/issues/251 - what version of asgiref are you running? Andrew On Tue, Apr 6, 2021, at 9:43 AM, kradem wrote: > > 500 Internal Server Error > > Exception inside application. > > Daphne > > This error raises every time a file from static f

Re: Channels, daphne, and asgiref, oh my!

2020-02-21 Thread Andrew Godwin
Hi Larry, Your problem is the Python version - 3.5 is somewhat old (but most importantly, was still a very rough release for asyncio) and isn't supported by any current release of asgiref/channels for that reason. If you are able to upgrade that, I very much recommend it. Andrew On Sat, Feb 22,

Re: Channels 2 using asyncio run_in_executor

2019-10-18 Thread Andrew Godwin
It should be fine, but you will need to be careful - there's a lot of side-effects with run_in_executor you should be aware of like the way exceptions propagate (Django won't handle them right for you) and the possibility of deadlock. Andrew On Fri, Oct 18, 2019 at 11:27 AM BR wrote: > Should I

Re: Channels: launching a custom co-routine from SyncConsumer

2019-08-15 Thread Andrew Godwin
SyncConsumer isn't async - it runs inside a separate synchronous thread. You'll need to get the event loop from the other thread and use call_soon_threadsafe instead! Andrew On Wed, Aug 14, 2019 at 6:59 PM Dan Merillat wrote: > > I have an application that's 99% using the ORM and database work

Re: Getting AttributeError: module 'asyncio' has no attribute '_get_running_loop'

2019-07-08 Thread Andrew Godwin
ents mentioned in > requirements.txt > > Rohit > > On Sun 7 Jul, 2019, 9:36 PM Andrew Godwin, wrote: > >> Hi Rohit, >> >> This is my fault - we made a change in the "asgiref" library that >> inadvertently removed Python 3.5 support. Channels still nee

Re: Getting AttributeError: module 'asyncio' has no attribute '_get_running_loop'

2019-07-07 Thread Andrew Godwin
Hi Rohit, This is my fault - we made a change in the "asgiref" library that inadvertently removed Python 3.5 support. Channels still needs to support it (even though Django doesn't). If you update to asgiref 3.1.4, which I've just released, that should fix the issue. Andrew On Sun, Jul 7, 2019

Re: Run Daphne as non-root on low ports

2019-05-02 Thread Andrew Godwin
e proxy with SSL termination at the > moment. > > On Thursday, May 2, 2019 at 9:49:41 AM UTC-4, Andrew Godwin wrote: >> >> Daphne does not have uid-changing built in, no - it's too simplistic for >> that, unfortunately. >> >> It's worth noting th

Re: Run Daphne as non-root on low ports

2019-05-02 Thread Andrew Godwin
Daphne does not have uid-changing built in, no - it's too simplistic for that, unfortunately. It's worth noting that systemd has this ability built in - it will listen on sockets for you and bind the socket to an application as needed. Otherwise, as the other poster noted, you can also use a rever

Re: how handle high incoming data and sending throttled data to web sockets in django-channels

2019-01-14 Thread Andrew Godwin
You'll have to design your own consumption architecture if you want to reliably handle 100 messages a second - since it's UDP, channels won't be handling it natively so you'll need to terminate and process the UDP yourself. I'd recommend either getting a UDP loadbalancer if you have messages coming

Re: channels and https

2018-12-28 Thread Andrew Godwin
You should use an ASGI server (uvicorn/daphne) with an SSL-terminating server (e.g. nginx) in front of it and proxying to it. Django-sslserver is a WSGI-based server and so can't support WebSockets. Andrew On Tue, Dec 25, 2018 at 4:44 PM wrote: > How can I use channels with https at developmen

Re: Django channels communication not asynchronous

2018-12-28 Thread Andrew Godwin
equire two websocket connections? One for requesting and another for > receiving responses Or am I going about it the wrong way > > On Monday, December 24, 2018 at 8:36:24 PM UTC+5:30, Andrew Godwin wrote: >> >> You appear to have missed an "await" before "s

Re: Django channels communication not asynchronous

2018-12-24 Thread Andrew Godwin
You appear to have missed an "await" before "self.send" - could that be the cause? In general, the best thing to do if things seem to "block" is to set the environment variable PYTHONASYNCIODEBUG=1 and Python will warn you if anything blocks for too long and seems synchronous. Andrew On Mon, Dec

Re: Error when installing channels

2018-12-24 Thread Andrew Godwin
This is a general problem with installing compiled Python packages on Windows. You'll need to install the compiler as outlined here: https://wiki.python.org/moin/WindowsCompilers (or search for "python visual c++ 14") Andrew On Sat, Dec 22, 2018 at 11:23 AM shiva kumar wrote: > Hai guys, I am g

Re: Error of channels

2018-12-17 Thread Andrew Godwin
I've seen a lot of people have a similar error but I'm never sure what causes it - that said, I generally advise them to check their Redis logs to see if Redis is OK, as that could cause this? Andrew On Mon, Dec 17, 2018 at 11:36 AM wrote: > I had an error while build a chatroom useing django-c

Re: Channels: development issue with multiple daphne workers

2018-11-27 Thread Andrew Godwin
I'm not sure why you're getting the _UnixSelectorEventLoop - that sounds like a Twisted error you should search around for, and make sure you have the right package versions. --fd 0 should not be needed in that command line, since you're already passing the UNIX socket, I don't remember why it's

Re: Django with Channels 2.1.1 Error During WebSocket handshake 404

2018-11-16 Thread Andrew Godwin
You cannot use gunicorn to run WebSockets or other async code - you need an ASGI server, like Daphne or uvicorn. Switch to one of those and it should start working. Andrew On Fri, Nov 16, 2018 at 8:11 PM Robert Fox wrote: > I am working on a project using Django and Channels 2.1.1. Everything i

Re: Channels + django-tenants

2018-11-14 Thread Andrew Godwin
Hm, that's not sufficiently better than just supplying a new middleware to be honest. The sort of hooks I prefer are where you can subclass and improve what we ship with and give the user a new, non-fragile one, whereas that just sounds like it's injecting a function in. Honestly, given Channels i

Re: Channels + django-tenants

2018-11-13 Thread Andrew Godwin
What sort of hook would you be imagining? The DB connection stuff is deep inside Django itself, rather than in Channels, so I'm not sure what sensible top-level thing we could provide that would make sense. Andrew On Tue, Nov 13, 2018 at 2:16 PM wrote: > Django-tenants is a package to provide m

Re: Channels group_send hangs in extrenal process

2018-11-13 Thread Andrew Godwin
I've never tried using the async-to-sync stuff with multiprocessing - first, I'd try removing that and see if it still works (just run from a management command or script directly). If it still fails, I'd suggest running a redis MONITOR to see if any traffic makes it to Redis at all. Andrew On T

Re: Channels: Test case fails on async.sleep(X>0)

2018-11-13 Thread Andrew Godwin
Couple of points: - Did you install pytest-django? That should help the settings thing. - There's a default 1-second timeout on get_response; pass timeout=4 to it and you should see that error go away. We have a default timeout because otherwise we can't tell if an async app has died/crashed and

Re: Django channels worker loses some messages

2018-11-11 Thread Andrew Godwin
Are you using Channels 1 or Channels 2? And which channel layer are you using? Andrew On Sun, Nov 11, 2018 at 5:05 AM Parsa Banihashemi < parsa.banihash...@gmail.com> wrote: > Hi, > I have a simple sync consumer which receives websocket messages from the > client, and each time, It passes a mess

Re: Channel: Migrate regular Django project to Channels2

2018-11-07 Thread Andrew Godwin
Channels doesn't take over at all unless you configure an async consumer. To make sure it's working I'd recommend writing a single async consumer, and running a test against that to ensure it works. Andrew On Wed, Nov 7, 2018 at 1:11 PM Zhiyu (Drew) Li wrote: > Hi there, > > I am trying to migr

Re: Adding Channels to and Existing Django Application

2018-11-06 Thread Andrew Godwin
he config files could help me set > this up. > > Juarez > > On Monday, November 5, 2018 at 9:24:39 PM UTC-2, Andrew Godwin wrote: >> >> Hey, >> >> You can just add channels to an existing Django project and only use it >> for the bits you need it for -

Re: Channels: event loop and thread

2018-11-06 Thread Andrew Godwin
Your assumptions are correct. The only extra thing to be aware of is that some Django interactions (like the Channels Auth middleware) need to do database connections and thus have to launch into a subthread for that, but that's also managed. Andrew On Tue, Nov 6, 2018 at 4:41 AM Zhiyu (Drew) Li

Re: Adding Channels to and Existing Django Application

2018-11-05 Thread Andrew Godwin
Hey, You can just add channels to an existing Django project and only use it for the bits you need it for - even down to running two different servers for that project, one normal WSGI one and one ASGI one to let you do async things. You shouldn't migrate any existing code to channels - just add

Re: How to subclass AsyncHttpConsumer for a GET request?

2018-10-30 Thread Andrew Godwin
put 'http': > MyAsyncHttpConsumer pair in the ProtocolRouter, all existing sync http > views stopped running as their type is "http" as well. So how to do a mix > of async HTTP and sync http? > Thanks > Drew > > On Mon, Oct 29, 2018, 23:15 Andrew Godwin wrot

Re: How to subclass AsyncHttpConsumer for a GET request?

2018-10-29 Thread Andrew Godwin
Yup, that's the right way - subclass the async consumer class and then write a handle method. You have to do your own post/get distinctions, like in a Django view, but with the scope rather than the request. Andrew On Mon, Oct 29, 2018 at 4:37 PM Zhiyu/Drew Li wrote: > Not sure if this is the b

Re: Channels -- a question about how ProtocolTypeRouter works

2018-10-26 Thread Andrew Godwin
i application -- a obj just lasts for one scope. > I need to go through the code deeper. > > Thanks > Drew > > > > On Fri, Oct 26, 2018 at 4:07 PM Andrew Godwin wrote: > >> Hi Drew, >> >> The return value is indeed an object, but if you look closely at it

Re: Channels -- a question about how ProtocolTypeRouter works

2018-10-26 Thread Andrew Godwin
Hi Drew, The return value is indeed an object, but if you look closely at it you'll see it defines a __call__ method - meaning that when it's called as an ASGI application, it then returns a further object to act inside the scope. Andrew On Fri, Oct 26, 2018 at 2:55 PM Zhiyu/Drew Li wrote: > H

Re: Channels: about max message size

2018-10-23 Thread Andrew Godwin
Hmm, it's possible the 0.x series didn't have response streaming for files so there'd be a limit, but I honestly can't remember, that was years ago. There's really not much I can do other than recommending an upgrade to something vaguely recent. Also make sure Heroku is not cutting you off with a

Re: [channels] 2.1.4 - Removing Javascript library entirely

2018-10-21 Thread Andrew Godwin
That's about right - you should ship and maintain the file yourself now. Andrew On Sun, 21 Oct 2018, 09:04 kradem, wrote: > Hi everyone! > > The subject is related to > https://github.com/django/channels/commit/2a9d764ad03927581aa2bfcadccc3e953949cb98 > > > It was very unmaintained, and having

Re: Channels: rejecting web socket connections with a custom close code

2018-10-06 Thread Andrew Godwin
Hi Matt, This is because the two ways of closing are different - closing before the socket is open sends a HTTP error code (what browsers report for this is different in terms of websocket errors), whereas closing once it is open allows a websocket error to be used. This is referenced in the spec

Re: Deploying Django app with Channels on Linux Hosting

2018-10-03 Thread Andrew Godwin
Hi there - it sounds like your host does not support websockets. You should check with them for more. Andrew On Wed, 3 Oct 2018 at 23:43, Manjunath wrote: > Hi all, > I have developed a simple app using django channels. > > I would like to deploy it on a linux hosting provider (Currently I have

Re: django ORM with asyncio

2018-09-18 Thread Andrew Godwin
The Django ORM can't just be used with asyncio directly, sadly. The database_sync_to_async function you found there will help you call the ORM from asynchronous code, but it still runs the ORM in a synchronous thread (see https://channels.readthedocs.io/en/latest/topics/databases.html) The project

Re: Channels thread count is increasing

2018-09-17 Thread Andrew Godwin
There's a reasonably large threadpool that sync_to_async uses (I think it defaults to number of CPU cores * 5), so you're probably just seeing that. It should stop growing at some point. Andrew On Sat, Sep 15, 2018 at 4:02 PM erkin kabataş wrote: > Hi All, > > I am new to python and django. > I

Re: Channels/Redis fault tolerance with Twemproxy?

2018-08-05 Thread Andrew Godwin
x27;t write against a read only slave. > > > Which I assume means Daphne doesn't detect a problem and just keeps the > socket open on the (old) master that is now the slave. > > > On Thursday, August 2, 2018 at 8:53:24 PM UTC-4, Andrew Godwin wrote: >> >>

Re: Channels/Redis fault tolerance with Twemproxy?

2018-08-02 Thread Andrew Godwin
x27;t > need some form of HA. Buried trying to get a product out the door right > now, but as I get time and more familiar with channels I'll probably dig in > deeper on this. > Thanks. > > On Thursday, August 2, 2018 at 7:32:52 PM UTC-4, Andrew Godwin wrote: >> >&

Re: Channels/Redis fault tolerance with Twemproxy?

2018-08-02 Thread Andrew Godwin
ay) three of them crash, will Channels continue to try and hash to the >> dead servers? Again, I'll accept a brief set of errors, but if this >> effectively causes Channels to continue to error that is not my definition >> of HA. >> Thanks. >> >> On Sunday, Ju

Re: Problem with sending django channels event from models

2018-07-31 Thread Andrew Godwin
cba067d4caa8bfcf22d683409531#file-test-py> > . > > https://gist.github.com/luanfonceca/dafecba067d4caa8bfcf22d683409531 > > > Thanks for everything, Andrew. > > Em sex, 27 de jul de 2018 às 19:30, Andrew Godwin > escreveu: > >> You need to post the full traceba

Re: Problem with sending django channels event from models

2018-07-27 Thread Andrew Godwin
You need to post the full traceback, not just the last section. I suspect what you are doing is calling model methods directly in an async function, but I can't confirm that without a full traceback. Andrew On Thu, Jul 26, 2018 at 1:10 PM luan fonceca wrote: > Hello, i'm trying to implement a "

Re: User Authenticated in Gunicorn and Daphne

2018-07-27 Thread Andrew Godwin
You can configure Nginx to route to different backends based on path - put your Nginx proxy_pass settings inside a "location" block. You can find examples on Stack Overflow - for example: https://stackoverflow.com/questions/13399252/nginx-reverse-proxy-to-multiple-backends Andrew On Tue, Jul 24,

Re: Connecting to remote host like Twitch to monitor chat using websockets

2018-07-24 Thread Andrew Godwin
Hi Dave, It depends on what the protocol for the chat room is, but Channels is more for hosting websocket-based applications than consuming them. I suspect you would be better off looking at websocket client libraries, if the chat socket is even accessible. Andrew On Mon, Jul 23, 2018 at 4:45 PM

Re: Channels/Redis fault tolerance with Twemproxy?

2018-07-22 Thread Andrew Godwin
lerance, correct? > > On Sunday, July 22, 2018 at 12:57:22 PM UTC-4, Andrew Godwin wrote: >> >> I'm afraid I've never used Twemproxy, so I can't really comment on it, >> but if you don't care about data loss, it's probably fine? >> >> Andrew

Re: Channels/Redis fault tolerance with Twemproxy?

2018-07-22 Thread Andrew Godwin
I'm afraid I've never used Twemproxy, so I can't really comment on it, but if you don't care about data loss, it's probably fine? Andrew On Fri, Jul 20, 2018 at 3:30 PM Filbert wrote: > Going to have 10 or more EC2 instances running Channels 2.0. I really > don't want to add the complexity of

Re: How to check if server is running in ASGI or in WSGI mode?

2018-07-22 Thread Andrew Godwin
Where do you want to detect this? There's no official way of knowing, because you're meant to detect based on features/what gets called. Andrew On Thu, Jul 19, 2018 at 2:12 PM Rafis Ganeev wrote: > We are running same django project in WSGI mode for handling HTTP requests > and in ASGI mode for

Re: [Channels] How to write tests with database access?

2018-07-22 Thread Andrew Godwin
Asynchronous testing is very hard, unfortunately. I suspect what you are doing is awaiting the sending of the message, but not awaiting any response back, so your test continues once it's sent the message into the application but not waiting for that application to finish processing. The best patt

Re: Django Channels: long running async function and where to save ORM object

2018-07-18 Thread Andrew Godwin
se async code inside that worker > process ? > While developing I simply do arun_serveron the command line -- > then I would always have to do arun_worker in addition -- right ? > > -Sebastian > > > On Mon, Jul 16, 2018 at 7:05 PM, Andrew Godwin > wrote: >

Re: Django Channels: long running async function and where to save ORM object

2018-07-16 Thread Andrew Godwin
You are correct in that you could store the model instance on "self" but this would result in caching issues, as that instance would not be updated after the initial socket connection. If you want to run "background routines", I would discourage you from doing these as random orphaned tasks launch

Re: [django-channels client wrapper] specifying no reconnection attempts

2018-07-15 Thread Andrew Godwin
I don't know much about that JavaScript code, I'm afraid, otherwise I would try and help (it's likely we're going to deprecate support for it soon as there's no maintainer for it right now anyway). Take a look through the source code and see if there's something you can call to stop reconnection a

Re: ERROR - server - Error trying to receive messages: name 'txredisapi' is not defined

2018-07-13 Thread Andrew Godwin
What version of Channels are you using? It looks like you're trying to use Channels 1 without Twisted redis support installed - did you try installing the package it's asking for? Andrew On Thu, Jul 12, 2018 at 4:22 AM Hank Chu wrote: > 2018-07-12 17:35:08,070 - INFO - worker - Listening on cha

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

2018-06-25 Thread Andrew Godwin
ote: > Hi Andrew - With Channels 2, can we have real-time audio/video streaming? > Thanks/Tirthankar. > > On Saturday, November 5, 2016 at 4:16:21 AM UTC+5:30, Andrew Godwin wrote: >> >> Hi Sandro, >> >> Real-time video streaming is pretty intensive, and WebRTC al

Re: Channels 2.0, How can I configure the channels 2.0 to use with the default django's views

2018-06-24 Thread Andrew Godwin
I'm not quite sure what you mean - Channels will still serve Django views as well unless you override HTTP serving as well as WebSocket, and even then, you can follow the URLRouter docs to keep it working fine: http://channels.readthedocs.io/en/latest/topics/routing.html#urlrouter Andrew On Thu,

Re: Channels 2.0 close code and http response status

2018-06-24 Thread Andrew Godwin
I'm not quite sure - WebSockets do have browser differences. You could also try adding a delay between the accept and the close to see if that changes how they handle it. Andrew On Sun, 24 Jun 2018, 06:02 Kirill Tyushchakov, wrote: > Hi, Andrew! Thanks a lot for your response. > I've changed my

Re: Channels 2.0 close code and http response status

2018-06-23 Thread Andrew Godwin
Hi! Close code 1006 means that the connection was closed abruptly by the other end (basically, the socket just got chopped off without an actual close frame being sent). This is what happens when you close during the handshake, which is what closing during connect() does - at that point, the conn

Re: Django Channels 2.0 - How to init and persist/communicate with only one instance of background worker for every channel_layer.send?

2018-06-23 Thread Andrew Godwin
g one channel name and my expectation is that only one > instance of the background worker class should be initiated/used. Instead, > I am seeing a new class being initiated for each call routed to the > background worker class. This is unexpected... > > > On Thursday, June 21, 201

Re: Django Channels 2.0 - How to init and persist/communicate with only one instance of background worker for every channel_layer.send?

2018-06-21 Thread Andrew Godwin
The worker server tries to keep one application instance open per incoming channel name, but that's no guarantee. It will always make a new instance for different channel names. What kind of behaviour are you expecting? Andrew On Tue, Jun 19, 2018 at 6:45 AM itsnate_b wrote: > I am using Django

Re: Django Channels 2.0 websocket crashing & blocking while using aiohttp

2018-06-17 Thread Andrew Godwin
I'm not quite sure why you seem to be using an AsyncConsumer outside of the context of the Channels routing framework? Anyway, it sounds like from what you're describing that your listen() method is blocking, which makes sense, as it connects to an external websocket and listens on it for messages

Re: Chatbot using Django Channels. Persist a python object in a scope?

2018-06-10 Thread Andrew Godwin
Hi! You can indeed have things persist for the entire scope - the Consumer (or any other ASGI app) does exactly this, and so if you're in a consumer you can just store things on "self". That'll be tied to a specific socket and garbage-collected once it's done (on Channels 2 only - channels 1 didn'

Re: Redirect Loops and 404 with Django Channels and runserver command

2018-06-09 Thread Andrew Godwin
Hi Justin, I'm going to reply to you on the ticket you opened at https://github.com/django/channels/issues/1075 with the same question :) Andrew On Fri, Jun 8, 2018 at 7:56 AM Justin Lee wrote: > I was just trying to integrate channels into an existing django/DRF > project and I have been runn

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 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: 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 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: 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: 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
- 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: 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: 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: 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: 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: 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: 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: 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: [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: 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: 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: 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: 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 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 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: 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: 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
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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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

  1   2   3   4   >