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

Make sure it is possible to register the file descriptors before delegating to asyncio #106

Merged
merged 1 commit into from
Mar 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions aioconsole/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import stat
import weakref
import asyncio
import selectors
from collections import deque
from threading import Thread
from concurrent.futures import Future
Expand All @@ -25,6 +26,14 @@ def is_pipe_transport_compatible(pipe):
is_socket = stat.S_ISSOCK(mode)
if not (is_char or is_fifo or is_socket):
return False
# Fail early when the file descriptor cannot be registered.
# This happens with docker containers for instance.
# See issue #102: https://github.com/vxgmichel/aioconsole/issues/102
try:
with selectors.DefaultSelector() as selector:
selector.register(fileno, selectors.EVENT_READ | selectors.EVENT_WRITE)
except OSError:
return False
return True


Expand Down