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

Invoke TConn().init() in gunicorn worker thread. #3308

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion gunicorn/workers/gthread.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def __init__(self, cfg, sock, client, server):
self.sock.setblocking(False)

def init(self):
if self.initialized:
return
self.initialized = True
self.sock.setblocking(True)

Expand Down Expand Up @@ -111,7 +113,6 @@ def _wrap_future(self, fs, conn):
fs.add_done_callback(self.finish_request)

def enqueue_req(self, conn):
conn.init()
# submit the connection to a worker
fs = self.tpool.submit(self.handle, conn)
self._wrap_future(fs, conn)
Expand Down Expand Up @@ -273,6 +274,7 @@ def handle(self, conn):
keepalive = False
req = None
try:
conn.init()
req = next(conn.parser)
if not req:
return (False, conn)
Expand Down
Loading