You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a problem wrapping my mind on the best way to implement this; I have this code in the consumers.py
import json
from channels import Group
from channels.sessions import channel_session
# Connected to websocket.connect
@channel_session
def ws_connect(message, key):
# Accept connection
message.reply_channel.send({"accept": True})
# Parse the query string
print message
#Get key and set using key
message.channel_session["key"] = key
#Set with key
Group("p-%s"%key).add(message.reply_channel)
#else:
# Close the connection.
#message.reply_channel.send({"close": True})
# Connected to websocket.receive
@channel_session
def ws_message(message, key):
reply = {}
json_response = json.dumps(reply)
Group("p-%s"%key).send({
"text": json_response,
})
# Connected to websocket.disconnect
@channel_session
def ws_disconnect(message, key):
Group("p-%s"%key).discard(message.reply_channel)
and I could either move it or import it in my program flow is for an image processing which should return the status of the process and final result.
for _ in range(x):
#insert code for ws_connect
...
if counter%100 == 0:
#send update (no further data is needed from user so it would be a ws_send like function)
#send proccessed result (ws_send)
#ws_disconnect
honestly this is far easier than celery and I hope you can help me finish setting it up.
also there's a part in you're docs where you have an import that doesn't work in python 2.7
In [1]: from urllib.parse import parse_qs
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-884805ae250f> in <module>()
----> 1 from urllib.parse import parse_qs
ImportError: No module named parse
The text was updated successfully, but these errors were encountered:
I have a problem wrapping my mind on the best way to implement this; I have this code in the consumers.py
and I could either move it or import it in my program flow is for an image processing which should return the status of the process and final result.
honestly this is far easier than celery and I hope you can help me finish setting it up.
also there's a part in you're docs where you have an import that doesn't work in python 2.7
The text was updated successfully, but these errors were encountered: