I have a python program that handles sensor data. Most of the functionality takes place locally and requires no network connection. The one thing i want it to do with a client is send a continuous stream of data IF a client is connected but for everything else to run regardless of weather there is a connected client or not. The only setups I've managed before all required a client to connect before anything else could happen. 
How do I set this up so my program doesn't depend on first having a client connected before it does anything??
Try to connect, and if it fails after n retries, consider you don't have a connection.
There are many strategies to setup retries, so search about it to figure what is best for you.
Then if you can't connect, just keep going on after the failure...
That's about it.
Python run certain functions with or without a client connection