Note that there are some explanatory texts on larger screens.

plurals
  1. POControlling scheduling priority of python threads?
    primarykey
    data
    text
    <p>I've written a script that uses two thread pools of ten threads each to pull in data from an API. The thread pool implements <a href="http://code.activestate.com/recipes/577187-python-thread-pool/" rel="noreferrer">this code on ActiveState</a>. Each thread pool is monitoring a Redis database via <a href="http://redis-py.readthedocs.org/en/latest/index.html#redis.StrictRedis.pubsub" rel="noreferrer">PubSub</a> for new entries. When a new entry is published, python passes the data to a function that uses python's <a href="http://docs.python.org/library/subprocess.html#popen-constructor" rel="noreferrer">Subprocess.POpen</a> to execute a PHP shell to do the actual work of calling the API.</p> <p>This system of launching PHP shells is necessary for functionality with my PHP web app, so launching PHP shells with Python can't be avoided.</p> <p>This script will only be running on Linux servers.</p> <p><del>How do I control the <a href="http://en.wikipedia.org/wiki/Nice_(Unix)" rel="noreferrer">niceness</a> (scheduling priority) of the application's threads?</del></p> <p><em>Edit:</em></p> <p>It seems controlling scheduling priority for individual threads in Python isn't possible. Is there a python solution, or at the very least a UNIX command I can run along with my script, to control the priority?</p> <p><em>Edit 2:</em></p> <p>Well I didn't end up finding a python way to handle it. I'm just running my script with nice now like this:</p> <pre><code>nice -n 19 python MyScript.py </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload