Oct-09-2018, 07:54 PM
Hi folks.
I have need to merge two bits of code, one is a very simple socket server and one is a reporting module that writes bumf to a mysql server at regular intervals. Both applications run independently perfectly well. So I thought I'd put both apps into functions and call them as threads.
Psudo code would be:
------------------------------------------
import blah, blah
def Reporter():
while True:
-DO MYSQL STUFF STUFF-
def SocketServer():
while True:
-ACCEPT AND PROCESS SOCKET DATA-
## Main
thread.start_new_thread(Reporter,(1,))
thread.start_new_thread(SocketServer,(1,))
------------------------------------------
The app spits out text here and there so I can see what's going on, and when I run the app both threads appear to get started, but then I get nothing. There's no pgrep id of the app, but n errors either. So, where does my app go?
Then if I run the app again I start getting random errors from lines of code that can't error, as if variables are completely messed up.
So what's happening with these threads that I wasn't expecting?
Many thanks.
I have need to merge two bits of code, one is a very simple socket server and one is a reporting module that writes bumf to a mysql server at regular intervals. Both applications run independently perfectly well. So I thought I'd put both apps into functions and call them as threads.
Psudo code would be:
------------------------------------------
import blah, blah
def Reporter():
while True:
-DO MYSQL STUFF STUFF-
def SocketServer():
while True:
-ACCEPT AND PROCESS SOCKET DATA-
## Main
thread.start_new_thread(Reporter,(1,))
thread.start_new_thread(SocketServer,(1,))
------------------------------------------
The app spits out text here and there so I can see what's going on, and when I run the app both threads appear to get started, but then I get nothing. There's no pgrep id of the app, but n errors either. So, where does my app go?
Then if I run the app again I start getting random errors from lines of code that can't error, as if variables are completely messed up.
So what's happening with these threads that I wasn't expecting?
Many thanks.