Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay between close() and reopening a server #43

Open
JPfeP opened this issue Aug 17, 2019 · 1 comment
Open

Delay between close() and reopening a server #43

JPfeP opened this issue Aug 17, 2019 · 1 comment

Comments

@JPfeP
Copy link

JPfeP commented Aug 17, 2019

Hello,

I had a bug showing only when trying to reopen a server with the same IP (or changing from 0.0.0.0 to 127.0.0.1) and same port settings after a close() function.

The error message is that the port is already in use.

Traceback (most recent call last):
  File "/home/hebus/.config/blender/2.80/scripts/addons/MOM/osc.py", line 107, in save_osc_port_in
    bpy.ops.mom.refresh_osc()
  File "/Graphisme/blender-2.80-linux-glibc217-x86_64/2.80/scripts/modules/bpy/ops.py", line 201, in __call__
    ret = op_call(self.idname_py(), None, kw)
RuntimeError: Error: Traceback (most recent call last):
  File "/home/hebus/.config/blender/2.80/scripts/addons/MOM/osc.py", line 140, in execute
    osc_server.listen(address=ip, port=port, default=True)
  File "/Graphisme/2.80_migration/MOM/oscpy/server.py", line 245, in listen
    sock.bind(addr)
OSError: [Errno 98] Address already in use

The solution I found was to introduce a delay using:
time.sleep(.01)

10ms was the minimal value to avoid the issue.

@JPfeP JPfeP changed the title Delay between close() and reopening a socket Delay between close() and reopening a server Aug 17, 2019
@tshirtman
Copy link
Member

Yes, i've add issues with that as well, tried adding a microsleep (with a much lower value than that), and the CI was still flacky, so for now i rely on retrying when that happens. But indeed it could be a good idea to make stop and stop_all do this directly. We can allow disabling it if people don't plan to reopen on the same port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants