Uwsgi docs says, that threads inside an application are turned off until you haven’t explicitly turned them on.
For me, it works not like that.
I have checked it through a simple view in django.
uwsgi run params:
- uwsgi
- --socket=0.0.0.0:8081
- --module=conf.shop.wsgi
- --buffer-size=65535
- --py-autoreload=1
- --lazy
- --lazy-apps
- --vacuum
When uwsgi starts, it writes:
*** Python threads support is disabled. You can enable it with –enable-threads ***
View code:
from threading import Thread
def view():
def foo(time_sleep, number: int):
time.sleep(time_sleep)
return number
results = {}
threads = []
for i in range(8):
thread = Thread(
target=foo,
kwargs={'time_sleep': 1, 'number': i},
name=f'task {i}',
)
threads.append(thread)
[thread.start() for thread in threads]
[thread.join() for thread in threads]
performed_threads = [thread for thread in threads if thread.result is not None]
for thread in performed_threads:
results[thread.name] = thread.result
return results
But this code works for 1s, not 8s.
I tried –strict and many other options, but didn’t find why it works in that way.
How to turn them off, if it is possible?
g10k is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.