danielbarter / mini_compile_commands

GNU General Public License v3.0
37 stars 3 forks source link

Address already in use error. #3

Closed henrybley closed 12 months ago

henrybley commented 1 year ago

sorry I'm a bit new to this and I apologize if I'm being dumb... but I had this working once or twice and got a generated .json but now when trying to run it I get this error and it blanks out my previous .json file


    self.server_bind()
  File "/nix/store/svjmllfy2w2byp5q53wb8w0j2fr605w3-python3-minimal-3.10.11/lib/python3.10/socketserver.py", line 466, in server_bind
    self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use```
danielbarter commented 1 year ago

Hey @henrybley, Thanks for opening the issue! this is almost surely happening because the unix socket file /tmp/mini_compile_commands_unix_socket is not being deleted when the server shuts down for some reason. A dumb way of fixing this would be to remove the file: rm /tmp/mini_compile_commands_unix_socket.

A few questions:

danielbarter commented 1 year ago

OK, i added a more useful exception message, which explains how to fix the problem. Pull main and try it out when you get a chance! Would still be good to understand a bit more about how you ran into this (especially if you are on macos). Leaving open for now

henrybley commented 1 year ago

thanks! that fixed it. I am using NixOS. Im not entirely sure what happened on my first time but I have been able to recreate the issue if I close the server down incorrectly. either by just shutting down the computer or closing the terminal window in which it is running

danielbarter commented 1 year ago

Yeah, that makes sense. The cleanup and json writing happen in a SIGINT handler, so if the process is killed another way, they don't happen.

There may be a way to fix this, but I suspect there will always be shutdown edge cases that don't work. For example, you can't have SIGKILL handlers: https://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html

The new exception message should help people recover, if they shut down abnormally.

Will leave open for now in case anyone can see a good solution

danielbarter commented 12 months ago

Closing since I think the added exception message is clear enough that people will be able to solve this on their own.