This recipe will show you how to write a function that polls the status of your Wi-Fi connection on boot-up. We will name this function wait_for_networking. Once it has detected that a connection has been successfully established and that an IP address has been assigned over DHCP, then the wait_for_networking function will return.
Whenever you have a project that requires internet connectivity, you will face this issue at boot-up. If your script starts immediately, connecting to the internet before the network connection has come up, it will raise exceptions and fail to continue. Using the method in this recipe will let you start the rest of your program's execution once the network connection is properly established.