fiftyone: [BUG] ServiceListenTimeout when using FiftyOne in Visual Studio Code

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04.7 LTS):
  • Linux Ubuntu 16.04
    
  • FiftyOne installed from (pip or source):
  • pip
  • FiftyOne version (run fiftyone --version):
  • 0.7.2
  • Python version:
  • 3.7.0

Commands to reproduce

As thoroughly as possible, please provide the Python and/or shell commands used to encounter the issue.

# commands here
python
import fiftyone

Describe the problem

Hello. Thank you for your product and your hard work. I have tried to install fiftyone on a remote server with Ubuntu 16.04 Below are the things I tried.

1.I tried running the following command before installing fiftyone, but I still have the below stacktrace: pip install --upgrade pip setuptools wheel

2.I also tried: pip install --index https://pypi.voxel51.com fiftyone-db-ubuntu1604 after installling fiftyone

3.Finally, I also installed mongoDB separately, but with no luck.

I have to mention that I also tried to install on a local Ubuntu 18.04.5 LTS system and this was ok. I was able to import the library in a python script.

If anything is unclear or you need more details, please let me know. Thank you

Other info / logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

{“t”:{“$date”:“2021-02-04T16:19:47.231Z”},“s”:“I”, “c”:“CONTROL”, “id”:20697, “ctx”:“main”,“msg”:“Renamed existing log file”,“attr”:{“oldLogPath”:“/home/mars/.fiftyone/var/lib/mongo/log/mongo.log”,“newLogPath”:“/home/mars/.fiftyone/var/lib/mongo/log/mongo.log.2021-02-04T16-19-47”}} Subprocess [‘/usr/bin/mongod’, ‘–dbpath’, ‘/home/mars/.fiftyone/var/lib/mongo’, ‘–logpath’, ‘/home/mars/.fiftyone/var/lib/mongo/log/mongo.log’, ‘–port’, ‘0’, ‘–nounixsocket’] exited with error 100: Uncaught exception Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “/home/mars/anaconda3/envs/fifty/lib/python3.7/site-packages/fiftyone/init.py”, line 28, in <module> from fiftyone.public import * File “/home/mars/anaconda3/envs/fifty/lib/python3.7/site-packages/fiftyone/public.py”, line 11, in <module> _database_service = fos.DatabaseService() File “/home/mars/anaconda3/envs/fifty/lib/python3.7/site-packages/fiftyone/core/service.py”, line 199, in init super().init() File “/home/mars/anaconda3/envs/fifty/lib/python3.7/site-packages/fiftyone/core/service.py”, line 80, in init self.start() File “/home/mars/anaconda3/envs/fifty/lib/python3.7/site-packages/fiftyone/core/service.py”, line 287, in start food.set_default_port(self.port) File “/home/mars/anaconda3/envs/fifty/lib/python3.7/site-packages/fiftyone/core/service.py”, line 277, in port return self._wait_for_child_port() File “/home/mars/anaconda3/envs/fifty/lib/python3.7/site-packages/fiftyone/core/service.py”, line 178, in _wait_for_child_port return find_port() File “/home/mars/anaconda3/envs/fifty/lib/python3.7/site-packages/retrying.py”, line 49, in wrapped_f return Retrying(*dargs, **dkw).call(f, *args, **kw) File “/home/mars/anaconda3/envs/fifty/lib/python3.7/site-packages/retrying.py”, line 212, in call raise attempt.get() File “/home/mars/anaconda3/envs/fifty/lib/python3.7/site-packages/retrying.py”, line 247, in get six.reraise(self.value[0], self.value[1], self.value[2]) File “/home/mars/anaconda3/envs/fifty/lib/python3.7/site-packages/six.py”, line 703, in reraise raise value File “/home/mars/anaconda3/envs/fifty/lib/python3.7/site-packages/retrying.py”, line 200, in call attempt = Attempt(fn(*args, **kwargs), attempt_number, False) File “/home/mars/anaconda3/envs/fifty/lib/python3.7/site-packages/fiftyone/core/service.py”, line 176, in find_port raise ServiceListenTimeout(etau.get_class_name(self), port) fiftyone.core.service.ServiceListenTimeout: fiftyone.core.service.DatabaseService failed to bind to port

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 2
  • Comments: 21 (8 by maintainers)

Most upvoted comments

@benjaminpkane Awesome, thank you!

In the meantime, I found a workaround for VSCode for others, as long as they’re not using mongodb for other things (I think). Worth a try at least.

Define a task to kill any mongodb processes before running debug:

In tasks.json:

{
    "tasks": [
        {
            "label": "Kill_Mongod",
            "type": "shell",
            "command": "pkill mongod"
        }
]}

And in launch.json:

{
    "configurations": [
        {
            "name": "Fiftyone_Download",
            "type": "python",
            "request": "launch",
            "preLaunchTask": "Kill_Mongod",
            "program": "~/fiftyone_download.py",
            "args": [
                "dataset_name=open-images-v6",
                "dataset_dir=/nvme/deep-learning/open-images-v6"
            ],
            "console": "integratedTerminal",
        }
]}

The key is the preLaunchTask above. Note if switching between debugging and the command line, you’ll need to manually run pkill mongod.

@benjaminpkane any updates on this?

I was able to reproduce. Will resolve ASAP.

OK. I think I figured it out. It seems that when I try to run fiftyone in a python script in VSCode the first time it works. Afterwards, when the script finishes, the mongoDB connection hangs and this is why I get the

fiftyone.core.service.ServiceListenTimeout: fiftyone.core.service.DatabaseService failed to bind to port

message.

I have to kill the mongo process by hand each time I run the script in VSCode, i.e. run: sudo netstat -nlp and get the mongo pid.

However, if I run in the terminal it works OK. No hung mongo DB connections. So, I have kind of a work-around for my issue, but if you have any idea for a clean fix, then please do tell.

Thank you @benjaminpkane

Ok. In the meantime I tried to trace what is causing a problem in my configuration. It seems this little feature of VSCode:

image

My scenario is a .devcontainer configuration based on the voxel51/fiftyone docker image. After app launch there is a pop-up with info about port redirecting on 5151, but a smaller one, in the corner as well. If I follow the suggestion and open a in-VSCode browser - everything works correctly. It seems the VS Code is itself internally proposing to show us the redirected port and keeps an alive connection, preventing a gracefull shutdown.

Configuring your own MongoDB connection is the recommended solution. A solution for the built-in database may be worked on in the future

I solved it with 2 lines in python before importing fiftyone,

import os
os.system('pkill mongod')

# then import fiftyone
import fiftyone

@MassimilianoBiancucci does it work on Windows?

Let me answer that: No, Windows equivalent is tskill.

I solved it with 2 lines in python before importing fiftyone,

import os
os.system('pkill mongod')

# then import fiftyone
import fiftyone

it’s simple but do its job, and you don’t need to lose time configuring any task in vscode

update: in this way, after several debug iterations the problem came back, you just need to run the code without the debugger active, and then you can run it again with the debugger.

@fcakyon Can you share more details about your environment? Remote/local, fiftyone version. I’m now having trouble reproducing.

My concern is that this will require some core changes to our services, which might be tricky. We’ll try to at least put a priority level on this this week, though.

@benjaminpkane still facing this issue on vs code. It makes debugging on vs code impossible with fiftyone. Are you still working on a solution?

This is helpful. I will try VSCode and get back to you. Thanks!