Do you have some advice? How should I start it and still be able to send all needed parameters there and use channels send()? When I start new Thread it still throws errors and when I start new Process then its broken and there i some fork error in the end.
Dne úterý 7. března 2017 19:45:36 UTC+1 Andrew Godwin napsal(a): > > So you are starting a steam client from a consumer inside a worker process > then? Inside a consumer, send() calls will not finish until you return > control from the consumer, so maybe that's it? > > On Tue, Mar 7, 2017 at 10:39 AM, Lada B <lada...@gmail.com <javascript:>> > wrote: > >> I call it in signal function after enough of user rows is in DB: >> >> @receiver(post_save, sender=chat_session) >> def on_create_users_online(sender, created, **kwargs): >> .... >> some magic conditions >> .... >> >> start_bot(kwargs['instance'].match_id, group1, group2,group_name, >> rad_reward, dire_reward, team1, team2) >> >> >> I will try to describe entire process...so: >> User connects to websocket and after they are added to group. All users >> in group are saved to DB chat_session table. >> Once enough users is connected to same group then steam client is started >> in signal function above. >> Then mess I explained above starts to happen. >> Even tho steam client is working properly, channels are not and daphne >> crashes because of block forever errors and backpressure. >> >> >> >> >> Dne úterý 7. března 2017 19:08:39 UTC+1 Andrew Godwin napsal(a): >>> >>> Where are you running this steam client from? Presumably not a webserver >>> process, as that doesn't have a main thread. Could you explain a bit more >>> about the architecture and what channel layers you have configured? >>> >>> Andrew >>> >>> On Tue, Mar 7, 2017 at 4:06 AM, Lada B <lada...@gmail.com> wrote: >>> >>>> I'm using >>>> >>>> https://github.com/ValvePython/steam >>>> https://github.com/django/channels >>>> >>>> and I'm trying to make them work together. Problem is that when >>>> SteamClient starts I cannot send any message with channels. >>>> >>>> Group(group_name).send({ >>>> 'text': json.dumps({ >>>> 'match_status': "balancing teams", >>>> }), >>>> }) >>>> >>>> This won't ever send message until SteamClient is running unless I put >>>> it to new thread. But when i do that I end up with: >>>> >>>> >>>>> gevent.hub.LoopExit: ('This operation would block forever', <Hub at >>>>> 0x7fc465aabd58 epoll pending=0 ref=0 fileno=27>) >>>> >>>> >>>> >>>> Example of my code: >>>> >>>> @client.on('logged_on') >>>> def start_dota(): >>>> Group(group_name).send({ >>>> 'text': json.dumps({ >>>> 'bot': getSteamProfile(str(client.steam_id)), >>>> }), >>>> }) >>>> >>>> dota.launch() >>>> dota.wait_event('lobby_removed') >>>> >>>> I'm trying to solve this for month already and I still cannot find out >>>> how. I just want to run gevent based SteamClient after i call it from main >>>> thread. I tried a lot, run it as new process, thread, for example: >>>> >>>> p = Thread(target=start_bot, args=(kwargs['instance'].match_id, group1, >>>> group2,group_name, rad_reward, dire_reward, team1, team2, )) >>>> p.start() >>>> >>>> When I start it as new thread I also get end up with >>>> gevent.hub.LoopExit: ('This operation would block forever', ........ >>>> >>>> or >>>> >>>> start_bot(kwargs['instance'].match_id, group1, group2,group_name, >>>> rad_reward, dire_reward, team1, team2) >>>> >>>> this doesn't send channels messages at all. >>>> >>>> Could anyone help me to solve this puzzle? I'm desperate. >>>> >>>> >>>> -- >>>> 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/f6c574c4-3449-4d95-be78-2db3451fcc3a%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/django-users/f6c574c4-3449-4d95-be78-2db3451fcc3a%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...@googlegroups.com <javascript:>. >> To post to this group, send email to django...@googlegroups.com >> <javascript:>. >> 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/fac65b2c-f7ad-4431-81c2-d86f8dc890f3%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/fac65b2c-f7ad-4431-81c2-d86f8dc890f3%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/ea8ac4d0-925f-4ad7-8610-c067ba438468%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.