I am new to using Balena and have hit an odd problem I’m hoping others may have solved. I have setup a single container application on Balena. The core of my application is written in Python 2.7. I have been able to build, deploy and run my application so far with minimal changes to the core code (which ran bare metal on RPI3). While the application runs fine for a period of time, eventually the container stops getting connections to Bluetooth devices and throws connection exceptions. If I restart the app container the problem continues. If I restart the host, the problem clears. It appears to happen after a period of time running the container, perhaps exhausting underlying connections at the OS level? My application is designed to retry BT connections (they are inherently unreliable with some devices, therefore catch a failure, close connection and retry is standard practice.). I am using the latest version of the BluePy library (https://github.com/IanHarvey/bluepy). Running in a bare metal configuration this library has not had connection problems, it just started w/the deployment to Balena. One thing that may be unique to my configuration is that I use Python multiprocessing to spawn sub processes that can run in parallel. I use process forking instead of threading due to some underlying behaviors of a library I’m using - has a bad habit of leaving abandoned sockets open. My using sub processes the orphans are destroyed w/the sub processes on exit. That approach works fine on bare metal, not sure what is happening w/balena under the covers when using this and potentially a problem w/BT connections? Any help to figure out what is happening would be appreciated.
job_thread = multiprocessing.Process(target=job_func)