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.

Reply via email to