# Running a thread in the nginx worker process cycle

**URL:** <https://www.ruby-forum.com/t/running-a-thread-in-the-nginx-worker-process-cycle/124312>\
**Category:** NGINX\
**Created:** [December 27, 2007, 3:52pm UTC](https://www.ruby-forum.com/t/running-a-thread-in-the-nginx-worker-process-cycle/124312 "2007-12-27T15:52:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manlio\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6f9a4e/32.png) [@Manlio\_P](https://www.ruby-forum.com/u/Manlio_P)\
**Post date:** [December 27, 2007, 3:52pm UTC](https://www.ruby-forum.com/t/running-a-thread-in-the-nginx-worker-process-cycle/124312/1 "2007-12-27T15:52:04Z")

</div>

Hi.

With mod\_wsgi I’m starting to testing threading usage in the Python  
application.

Do I have to take some precautions when starting a new thread?  
In the nginx sources I see that some signals are blocked.

Above all, it is safe to start a new thread?

Thanks Manlio P.

---

<div class="post-metadata">

**Author:** ![Manlio\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6f9a4e/32.png) [@Manlio\_P](https://www.ruby-forum.com/u/Manlio_P)\
**Post date:** [December 27, 2007, 4:07pm UTC](https://www.ruby-forum.com/t/running-a-thread-in-the-nginx-worker-process-cycle/124312/2 "2007-12-27T16:07:54Z")

</div>

On Thu, Dec 27, 2007 at 03:39:10PM +0100, Manlio P. wrote:

> With mod\_wsgi I’m starting to testing threading usage in the Python  
> application.
> 
> Do I have to take some precautions when starting a new thread?  
> In the nginx sources I see that some signals are blocked.
> 
> Above all, it is safe to start a new thread?

It’s not simple question. I can not say right now.

---

<div class="post-metadata">

**Author:** ![Manlio\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6f9a4e/32.png) [@Manlio\_P](https://www.ruby-forum.com/u/Manlio_P)\
**Post date:** [December 27, 2007, 4:44pm UTC](https://www.ruby-forum.com/t/running-a-thread-in-the-nginx-worker-process-cycle/124312/3 "2007-12-27T16:44:17Z")

</div>

Igor S. ha scritto:

> It’s not simple question. I can not say right now.

Ok, thanks.

I will try to do some better tests, however the WSGI application at:  
[http://hg.mperillo.ath.cx/nginx/mod\_wsgi/file/tip/examples/nginx-thread-pool.py](http://hg.mperillo.ath.cx/nginx/mod_wsgi/file/tip/examples/nginx-thread-pool.py)  
seems to work, even with an high level of concurrency.

By the way, there is an interesting post about a multithreaded python  
application embedded in PostgreSQL (with plpython):  
[http://mail.python.org/pipermail/python-list/2007-December/468320.html](http://mail.python.org/pipermail/python-list/2007-December/468320.html)

In that case, Tome Lane response is simply:  
Don’t even _think_ about starting multiple threads inside the Postgres  
backend. It’s an excellent way to break things.

Manlio P.
