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

ValueError: Invalid file descriptor: -1 in asyncio #23

Open
garrison opened this issue Apr 15, 2022 · 3 comments
Open

ValueError: Invalid file descriptor: -1 in asyncio #23

garrison opened this issue Apr 15, 2022 · 3 comments

Comments

@garrison
Copy link
Contributor

garrison commented Apr 15, 2022

I often (but not always) witness treon output the following error just before exiting:

Exception ignored in: <function BaseEventLoop.__del__ at 0x7fbaf2e4a4c0>
Traceback (most recent call last):
  File "/usr/lib64/python3.8/asyncio/base_events.py", line 656, in __del__
    self.close()
  File "/usr/lib64/python3.8/asyncio/unix_events.py", line 58, in close
    super().close()
  File "/usr/lib64/python3.8/asyncio/selector_events.py", line 92, in close
    self._close_self_pipe()
  File "/usr/lib64/python3.8/asyncio/selector_events.py", line 99, in _close_self_pipe
    self._remove_reader(self._ssock.fileno())
  File "/usr/lib64/python3.8/asyncio/selector_events.py", line 276, in _remove_reader
    key = self._selector.get_key(fd)
  File "/usr/lib64/python3.8/selectors.py", line 190, in get_key
    return mapping[fileobj]
  File "/usr/lib64/python3.8/selectors.py", line 71, in __getitem__
    fd = self._selector._fileobj_lookup(fileobj)
  File "/usr/lib64/python3.8/selectors.py", line 225, in _fileobj_lookup
    return _fileobj_to_fd(fileobj)
  File "/usr/lib64/python3.8/selectors.py", line 42, in _fileobj_to_fd
    raise ValueError("Invalid file descriptor: {}".format(fd))
ValueError: Invalid file descriptor: -1

Treon then goes on to exit with a successful error code, so it's effectively just a warning, even though it is caused by a ValueError. I've witnessed this on multiple versions of python..

I typically invoke treon as treon . --threads 2. I suspect this warning might go away if I don't use threads, but I haven't investigated it yet.

@amit1rrr
Copy link
Member

amit1rrr commented Apr 16, 2022

@garrison thanks for reporting.

So treon doesn't use asyncio (at least not directly), we use ThreadPool for parallelisation. Can we see a longer stack trace? I'm thinking the error might be coming from actual notebook code cell execution that happens as part of running the notebook for testing.

@garrison
Copy link
Contributor Author

@amit1rrr That's very interesting.

There is nothing more to the stacktrace beyond what I posted.

None of my notebooks call asyncio directly, either, and to the best of my knowledge they are not calling any code that would rely on asyncio. I'm going to pay careful attention to the circumstances in which I can reproduce this. Maybe there's something special about one of the notebooks I am testing against. Or maybe I will find that I can reproduce it even with a single, very simple notebook. I'll keep you posted.

@amit1rrr
Copy link
Member

Yes, if it's possible to reproduce it consistently on some notebooks then it would be easier to dig deeper.

I typically invoke treon as treon . --threads 2. I suspect this warning might go away if I don't use threads, but I haven't investigated it yet.

This might also be a good elimination strategy. If we're suspecting this happens as part of notebook code cell execution then it should happen even when treon is running single threaded. If it does not happen then there's something within treon (or it's dependencies) that needs fixing.

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