twitter-archive / torch-ipc

A set of primitives for parallel computation in Torch
Apache License 2.0
95 stars 28 forks source link

Address already in use? #41

Closed juesato closed 7 years ago

juesato commented 7 years ago

Hi, Thanks for writing this library - I've really enjoyed using it so far. One small issue I have is that if I cancel a process halfway through (ctrl+c), and then try to restart it, I frequently get the following error.

ERROR: (/tmp/luarocks_ipc-scm-1-7755/torch-ipc/src/cliser.c, 226): (98, Address already in use)

My understanding is that this is due to the socket needing to clear (and indeed after killing all the processes and waiting the error will go away). I'm wondering if there's a faster way to deal with this rather than just waiting.

EDIT for other people / google: I believe the best solution is to change / randomize the port number on every run. netstat -ntp shows sockets still in TIME_WAIT state. See http://stackoverflow.com/questions/5106674/error-address-already-in-use-while-binding-socket-with-address-but-the-port-num/5106755#5106755 for more information.