Re: Channels with django signals
Oh I saw that you fixed it recently. Thank you anyway :) On Sunday, February 4, 2018 at 1:22:58 AM UTC+1, Andrew Godwin wrote: > > 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 use the >> AsyncToSync wrapper. >> But it seems this is not possible as the signal handler is run by a >> thread and has no event loop. >> >> ... >> self.main_event_loop = asyncio.get_event_loop() >> File "/usr/lib/python3.5/asyncio/events.py", line 632, in get_event_loop >> return get_event_loop_policy().get_event_loop() >> File "/usr/lib/python3.5/asyncio/events.py", line 578, in get_event_loop >> % threading.current_thread().name) >> RuntimeError: There is no current event loop in thread 'Thread-2'. >> >> So I tried to create the AsyncToSync inside the app.py as this gets >> executed by the main thread. By passing this instance I tried to execute >> the wrapper inside >> the signal handler. But this also doesn't work and the website is stuck >> loading. How can I get around this issue? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users...@googlegroups.com . >> To post to this group, send email to django...@googlegroups.com >> . >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/ddda3ff6-79f9-43b8-a201-5792512564d7%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/ddda3ff6-79f9-43b8-a201-5792512564d7%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6fcca1b6-a336-41a0-b7e6-e9024adf560e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Channels with django signals
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 use the AsyncToSync wrapper. But it seems this is not possible as the signal handler is run by a thread and has no event loop. ... self.main_event_loop = asyncio.get_event_loop() File "/usr/lib/python3.5/asyncio/events.py", line 632, in get_event_loop return get_event_loop_policy().get_event_loop() File "/usr/lib/python3.5/asyncio/events.py", line 578, in get_event_loop % threading.current_thread().name) RuntimeError: There is no current event loop in thread 'Thread-2'. So I tried to create the AsyncToSync inside the app.py as this gets executed by the main thread. By passing this instance I tried to execute the wrapper inside the signal handler. But this also doesn't work and the website is stuck loading. How can I get around this issue? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ddda3ff6-79f9-43b8-a201-5792512564d7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Getting channels 2 to work
Hi Andrew, first of all thanks for your reply. With your answer and the information from your blog I was able to get my asgi application running. Now I want to route all http traffic to django's viewsystem back as i dont need channel's http handling. On your blog 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 Friday, December 1, 2017 at 6:22:06 PM UTC+1, Andrew Godwin wrote: > > 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/deploying.html > - Make a channels.routing.ProtocolTypeRouter in your project's routing.py > and configure this as needed (you'll have to read the code for now) > - Point ASGI_APPLICATION to that root router. > > I'll have a lot more docs and stuff coming soon as I start prepping > Channels 2 for a beta release, which will include routing and setup > examples. > > Andrew > > On Fri, Dec 1, 2017 at 6:03 AM, John Wayne > wrote: > >> Hi everyone, >> >> I am stuck getting the new channels 2 to a working state. I installed >> django==2.0rc1, and channels==2.0.x, daphne==2.0.x, asgiref==2.0.x from >> the git repo >> channels is enabled inside the settings.py. I also created the asgi.py >> file in the direcotry of the wsgi.py file acording to the docs. But still i >> get this error >> >> raise ImproperlyConfigured("Cannot find ASGI_APPLICATION setting.") >> django.core.exceptions.ImproperlyConfigured: Cannot find ASGI_APPLICATION >> setting. >> >> So it seems that ASGI_APPLICATION has to be specified. So after adding >> the following line: >> ASGI_APPLICATION='mytestproject.asgi.application' >> and starting ./manage.py runserver it now complains again. So which value >> is supposed to be there? >> >> raise ImproperlyConfigured("Cannot find %r in ASGI_APPLICATION >> module %s" % (name, path)) >> django.core.exceptions.ImproperlyConfigured: Cannot find 'application' in >> ASGI_APPLICATION module mytestproject.asgi >> >> I need to stick to version 2 as i want to try out asgigram ( >> https://github.com/andrewgodwin/asgigram). >> >> Thanks >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users...@googlegroups.com . >> To post to this group, send email to django...@googlegroups.com >> . >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/3c426628-13da-4ad3-8e4c-3e8938ab0c8d%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/3c426628-13da-4ad3-8e4c-3e8938ab0c8d%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/22ceb8b4-e28e-4301-857a-3fffb211e5a9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Getting channels 2 to work
Hi everyone, I am stuck getting the new channels 2 to a working state. I installed django==2.0rc1, and channels==2.0.x, daphne==2.0.x, asgiref==2.0.x from the git repo channels is enabled inside the settings.py. I also created the asgi.py file in the direcotry of the wsgi.py file acording to the docs. But still i get this error raise ImproperlyConfigured("Cannot find ASGI_APPLICATION setting.") django.core.exceptions.ImproperlyConfigured: Cannot find ASGI_APPLICATION setting. So it seems that ASGI_APPLICATION has to be specified. So after adding the following line: ASGI_APPLICATION='mytestproject.asgi.application' and starting ./manage.py runserver it now complains again. So which value is supposed to be there? raise ImproperlyConfigured("Cannot find %r in ASGI_APPLICATION module %s" % (name, path)) django.core.exceptions.ImproperlyConfigured: Cannot find 'application' in ASGI_APPLICATION module mytestproject.asgi I need to stick to version 2 as i want to try out asgigram (https://github.com/andrewgodwin/asgigram). Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3c426628-13da-4ad3-8e4c-3e8938ab0c8d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.