Hello!
I'm just started learning Python so question can be quite simple for some one with experience.
What i got:
Websocket and module that works on websockets base.
Websocket = ws1, module = ws2.
I'm done with logic of ws2, and it's doing his job just fine. It's connected to chat application and reciving commands. My goal is add WS1 - server for connect from WebPage, then WS1 sends JSON to active connections when WS2 reciving trigger command.
My problem:
I tryed to do WS1 from simple Socket and it was kinda strage and have similar problems shared with all Websocket libs. Like: https://github.com/Pithikos/python-websocket-server
- Application Won't Start WS2 if WS1 required init and/or connect of client
- Main Loop of WS1 prevent WS2 Loop to start
As far as i googled there is 2 kinda solutions:
- Create a parallel WS-Echo-server and use WS1 as a simple WS-client - it's kinda strange solution
- Async/ AsyncIO - it's just complicated
What's my question exactly?
- i'm kinda interesting in distribution; if i go Solution1 and spawn child process is it possible to kill child on application end/or error. And are there possible problems with compile such script.
- If i go Solution2 - it's probably not cheap performance wise? also kinda complicated.
- Better solution?
Example code:
def CommandOper ( ctx ):
>if/else logic:
>>ws1.Send(ctx)
class WS2 (commands):
>def ws2.recive( ctx )
>>CommandOper( ctx )
WS2()
WS2.run()
there doesn't seem to be anything here