Oct-21-2018, 02:55 AM
i'm not sure which thread to answer. but you should try better to resolve the connection failure. if you are really trying to have your program do other stuff while the connecting is trying to be made, then yeah, a separate thread or process is needed so the connection is being tried in parallel, regardless whether or not it will fail.
it's not clear what you are doing. is it on thread for each of many servers the client connects to?
i wrote a script a while back that connects to several (11 of them if i recall) of those web sites that shows you IP address. it connects to them all using processes (instead of threads). but it handles connection failures gracefully because there are almost always a few that fail. it waits until all processes are done which means the one that took the longest time affects the timing of the script, whether it succeeds or fails. i think i put a timeout in there because a successful connection could be the worst case and wait forever. connection failures get timed out by the system, but an established connection could, in theory, wait for years ... or longer.
the reason i made this connection to many servers is because many of them could be down at the same time. many of the cloud scripts i run need to know what IP address they will be seen as coming from so they can make various requests properly, like setting up cloud security group rules. i would not want to depend on just one server since all of them have had some down time (even Google).
i also have other scripts doing multiprocessing. i generally don't use threads. so i really can't help with the specific difficulties of threads over processes.
maybe if you describe more of what you are doing, it could help. what operating system(s) are you using? Windows? OSX? Linux? BSD? what is your reason for choosing threads instead of processes (all those systems have both choices)?
please reply in this thread so everyone else can read both posts.
it's not clear what you are doing. is it on thread for each of many servers the client connects to?
i wrote a script a while back that connects to several (11 of them if i recall) of those web sites that shows you IP address. it connects to them all using processes (instead of threads). but it handles connection failures gracefully because there are almost always a few that fail. it waits until all processes are done which means the one that took the longest time affects the timing of the script, whether it succeeds or fails. i think i put a timeout in there because a successful connection could be the worst case and wait forever. connection failures get timed out by the system, but an established connection could, in theory, wait for years ... or longer.
the reason i made this connection to many servers is because many of them could be down at the same time. many of the cloud scripts i run need to know what IP address they will be seen as coming from so they can make various requests properly, like setting up cloud security group rules. i would not want to depend on just one server since all of them have had some down time (even Google).
i also have other scripts doing multiprocessing. i generally don't use threads. so i really can't help with the specific difficulties of threads over processes.
maybe if you describe more of what you are doing, it could help. what operating system(s) are you using? Windows? OSX? Linux? BSD? what is your reason for choosing threads instead of processes (all those systems have both choices)?
please reply in this thread so everyone else can read both posts.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.