Re: Channels: development issue with multiple daphne workers

2018-11-27 Thread Zhiyu/Drew Li
d line, since you're already > passing the UNIX socket, I don't remember why it's there. > > I suggest you remove fd=0 and see if that then works with multiple > processes. > > Andrew > > On Mon, Nov 26, 2018 at 3:10 PM Zhiyu (Drew) Li > wrote: > >> Hi there, >>

Channels: development issue with multiple daphne workers

2018-11-26 Thread Zhiyu (Drew) Li
Hi there, I am trying to migrate a tornado project to django channel2. I have moved all essential parts and wired them up in channel. It runs OK in development mode, but in production it seems the multi-daphne worker configuration is causing strange errors. AttributeError:

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

2018-11-12 Thread Zhiyu (Drew) Li
Hi there, I was trying to write a test for a consumer. It is just a very simply AsyncHttpConsumer subclass that awaits on asyncio.sleep(3) and returns a "OK" in plain text. The test case is: @pytest.mark.asyncio async def test_my_consumer(): communicator = HttpCommunicator(BasicHttpConsumer,

Re: Channel: Migrate regular Django project to Channels2

2018-11-09 Thread Zhiyu/Drew Li
y, November 7, 2018 at 8:56:52 PM UTC-7, Andrew Godwin wrote: > > 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. > &g

Channel: Migrate regular Django project to Channels2

2018-11-07 Thread Zhiyu (Drew) Li
Hi there, I am trying to migrate an existing Django project to Channels2. We want to keep all existing sync codes unchanged and we will continue mode of the development in sync mode. But having Channels opens the opportunity to develop some features in async mode. I was able to install channels2

Channels: event loop and thread

2018-11-06 Thread Zhiyu (Drew) Li
Hi there, I got the following 2 questions There is only one thread (MainThread) and one event loop running on it by default if all existing consumers are asynchronous consumers? Regular sync views (if any) are handled by Threadpoolexecutor and run in a sub Thread. These sync views won't block

Re: How to subclass AsyncHttpConsumer for a GET request?

2018-10-30 Thread Zhiyu (Drew) Li
win wrote: > 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 Zhiy

Re: How to subclass AsyncHttpConsumer for a GET request?

2018-10-29 Thread Zhiyu/Drew Li
Not sure if this is the best way. I just found inside AsyncHttpConsumer.handle() I can access self.scope['method'] to determine if it is a GET or POST or others. Thanks Drew On Monday, October 29, 2018 at 3:50:43 PM UTC-6, Zhiyu/Drew Li wrote: > > Hi there, > > Newbie to Cha

How to subclass AsyncHttpConsumer for a GET request?

2018-10-29 Thread Zhiyu (Drew) Li
Hi there, Newbie to Channels. I am trying to write a Async consumer to handle a http GET request How to write a subclass MyAsynHttpConsumer(AsyncHttpConsumer) for this purpose? Or I am looking at the wrong class? Also if I understand correctly, I should manually add a new pair 'http':

Re: Channels -- a question about how ProtocolTypeRouter works

2018-10-26 Thread Zhiyu (Drew) Li
further object to act inside the scope. > > Andrew > > On Fri, Oct 26, 2018 at 2:55 PM Zhiyu/Drew Li wrote: > >> Hi, >> >> Newbie here. (please bear with me if this a stupid question) >> >> I am going through the tutorial and doc and got this question regar

Channels -- a question about how ProtocolTypeRouter works

2018-10-26 Thread Zhiyu/Drew Li
Hi, Newbie here. (please bear with me if this a stupid question) I am going through the tutorial and doc and got this question regarding how ProtocolTypeRouter works. ProtocolTypeRouter.__init__ takes a dict "application_mapping" and append a key-value pair to it: "http': class AsgiHandler