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

Remove socketfromfd dependency to be able to launch thumbor with the --fd option #1422

Merged
merged 4 commits into from Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -133,7 +133,6 @@ def run_setup(extension_modules=None):
"Pillow>=9.0.0",
"pytz>=2019.3.0",
"statsd==3.*,>=3.3.0",
"socketfromfd>=0.2.0",
"tornado==6.*,>=6.0.3",
"webcolors==1.*,>=1.10.0",
"colorful==0.*,>=0.5.4",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_server.py
Expand Up @@ -196,7 +196,7 @@ def test_can_run_server_with_multiple_processes(self, server_mock):
server_instance_mock.start.assert_called_with(5)

@mock.patch.object(thumbor.server, "HTTPServer")
@mock.patch.object(thumbor.server, "socket_from_fd")
@mock.patch.object(thumbor.server, "socket")
def test_can_run_server_with_fd(self, socket_from_fd_mock, server_mock):
application = mock.Mock()
context = mock.Mock()
Expand Down
7 changes: 2 additions & 5 deletions thumbor/server.py
Expand Up @@ -15,10 +15,10 @@
import warnings
from os.path import dirname, expanduser
from shutil import which
from socket import socket

import tornado.ioloop
from PIL import Image
from socketfromfd import fromfd as socket_from_fd
from tornado.httpserver import HTTPServer
from tornado.netutil import bind_unix_socket

Expand Down Expand Up @@ -112,10 +112,7 @@ def run_server(application, context):
fd_number = get_as_integer(context.server.fd)

if fd_number is not None:
# TODO: replace with socket.socket(fileno=fd_number) when we require Python>=3.7
sock = socket_from_fd( # pylint: disable=too-many-function-args
fd_number, True
)
sock = socket(fileno=fd_number)
else:
sock = bind_unix_socket(context.server.fd)

Expand Down