> Hi everybody,
>
> I'm a little confused about the "--enable-threads" option. The
> documentation says that user-created threads will never run without
> --enable-threads (because the GIL never gets created) but when I run the
> following, it works just fine:
>
> a = []
> def my_thread(i):
>     time.sleep(0.5)
>     for i in xrange(10):
>         a.append(i)
>
> class application(object):
>
>     def __init__(self, environ, start_response):
>         start_response('200 OK', [])
>
>     def __iter__(self):
>         threads = []
>         for i in xrange(10):
>             t = threading.Thread(target=my_thread, args=(i,))
>             threads.append(t)
>         for t in threads:
>             t.start()
>         yield str(len(a)) + '\n'
>         for t in threads:
>             t.join()
>         yield str(len(a)) + '\n'
>
>
> Running with command line:
>
> $ uwsgi --plugins=python,http --file ~/path/to/app.py --http :9999
>
> $ curl http://localhost:9999/
> 0
> 100
>
> Adding --enable-threads or --threads <n> doesn't change the output.
>
> Is the documentation out of date? Or does using not enabling threads mean
> something dangerous could be happening, like threads running without the
> GIL, etc?
>
> Thanks
> Duncan
>

Hi, it "looks" it work because thread can be started even without managing
the GIL, but as soon as you need to come back to uWSGI, thread will never
get again the GIL. Try daemonizing the threads (no-join) and you will see
how they will stop running after the end of the WSGI callable

-- 
Roberto De Ioris
http://unbit.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to