I was running an experiment and I found that the function close() from coap was not really closing the socket.
Thereby, I added the following command in the file openwsn/coap/coap/SocketUdpReal.py:
declare that this thread has to stop
self.goOn = False
send some dummy value into the socket to trigger a read
self.socket_handler.sendto( 'stop', ('::1',self.udpPort) )
self.socket_handler.close() #line added
wait for this thread to exit
Now it is working.
I am using a ubuntu version.