Fix for issue #3079, worker_class parameter accepts a class

This commit is contained in:
Odysseas Fatouros 2023-10-13 16:15:40 +02:00
parent 430dcdd997
commit ca2ce2c76b

View File

@ -103,18 +103,20 @@ class Config(object):
def worker_class_str(self):
uri = self.settings['worker_class'].get()
# are we using a threaded worker?
is_sync = uri.endswith('SyncWorker') or uri == 'sync'
if is_sync and self.threads > 1:
return "gthread"
return uri
if isinstance(uri, str):
# are we using a threaded worker?
is_sync = uri.endswith('SyncWorker') or uri == 'sync'
if is_sync and self.threads > 1:
return "gthread"
return uri
return uri.__name__
@property
def worker_class(self):
uri = self.settings['worker_class'].get()
# are we using a threaded worker?
is_sync = uri.endswith('SyncWorker') or uri == 'sync'
is_sync = isinstance(uri, str) and (uri.endswith('SyncWorker') or uri == 'sync')
if is_sync and self.threads > 1:
uri = "gunicorn.workers.gthread.ThreadWorker"