Open jofas opened 4 years ago
There are general issues with sockets not being closed sometimes. A better "workaround" then is to ask the tools to bind to a random socket each time.
An example of this is:
import spinnaker_graph_front_end as gfe
from spinn_front_end_common.utilities.connections import LiveEventConnection
from spinn_front_end_common.utilities.constants import NOTIFY_PORT
from spinn_front_end_common.utilities.globals_variables import get_simulator
from spinn_utilities.socket_address import SocketAddress
def execute_application_on_spinnaker_with_live_io():
# setup some graph
# ...
gfe.setup(...)
conn = LiveEventConnection(..., local_port=None)
database_socket = SocketAddress(
listen_port=22222,
notify_host_name="127.0.0.1",
notify_port_no=conn.local_port
)
get_simulator().add_socket_address(database_socket)
gfe.run(10)
gfe.stop()
conn.close()
execute_application_on_spinnaker_with_live_io()
execute_application_on_spinnaker_with_live_io()
This reverses the order, creating the socket first but asking for a random port (local_port=None
) and then requests the port that the socket bound to in the add_socket_address call (conn.local_port
). Note that you may also run into trouble with the listen_port, which I think can be set to None
in general I think.
Hi all,
I recently realized that I can't run my application two times within the same program, because the socket used for the
LiveEventConnection
somehow isn't properly closed (according to my OS). System resources like sockets are always tricky I guess.My program looks something like this:
And for the second execution of
execute_application_on_spinnaker_with_live_io()
I receive the following error (with stracktrace from the real program I tried running):I researched a little and found a way to tell the OS that sockets are reused. So I added
to the
get_socket()
function here, but it did not work unfortunately. With this line added I don't receive an error no more, but the secondLiveEventConnection
sometimes sends packets and sometimes doesn't.Maybe I'm making a mistake setting up the socket in the first place?
Kind regards, Jonas