This lets us shutdown the server (and also the agent) cleanly.
As described on Slack, with recvfrom() it's not guaranteed for us to be unblocked when the socket is closed. It just happened that on macOS we got an exception when the socket was closed. On Linux, this wasn't the case and so the reader thread would be blocked indefinitely.
So the recommended approach is to use select(), which will block the thread until a timeout or until the socket is ready to be read (whichever occurs first). In practice this means we check the _shutdown_requested flag at least every SELECT_TIMEOUT seconds.
This also adds some __init__.py files and makes the server bind to all interfaces by default.
This lets us shutdown the server (and also the agent) cleanly.
As described on Slack, with
recvfrom()
it's not guaranteed for us to be unblocked when the socket is closed. It just happened that on macOS we got an exception when the socket was closed. On Linux, this wasn't the case and so the reader thread would be blocked indefinitely.So the recommended approach is to use
select()
, which will block the thread until a timeout or until the socket is ready to be read (whichever occurs first). In practice this means we check the_shutdown_requested
flag at least everySELECT_TIMEOUT
seconds.This also adds some
__init__.py
files and makes the server bind to all interfaces by default.