Note that there are some explanatory texts on larger screens.

plurals
  1. POuWSGI, cherrypy and threading
    primarykey
    data
    text
    <p>preface: I would like to separate these problems into smaller questions, but apparently, I am missing some pieces of the puzzle and it seems impossible to me. </p> <p>I developed my cherrypy application using cherrypy's built in WSGI server. I naively assumed that when the time comes, I will be able to use created WSGI Application class and deploy it using any WSGI compliant server.</p> <p>I used <a href="http://www.defuze.org/archives/222-integrating-sqlalchemy-into-a-cherrypy-application.html" rel="nofollow">this blog post</a> to create my own (but very similar) cherrypy Plugin and Tool to connect to database using SQLAlchemy during http requests.</p> <p>I expected that any server will somehow work like cherrypy's built in server:</p> <ol> <li>main process will spawn X threads to satisfy X concurrent requests</li> <li>my engine Plugin will create SQLalchemy engine with connection pool = X (so any request will have its connection)</li> <li>on request arrival, my Tool will supply sql alchemy connection from pool</li> </ol> <p>This flow does not match with uWSGI (as long as I understand it). </p> <p>I assign my <code>application.py</code> in uWSGI configuration. This file looks something like this:</p> <pre><code>cherrypy.tools.db = DbConnectorTool() cherrypy.engine.dbengine = DbEnginePlugin(cherrypy.engine, settings.database) cherrypy.config.update({ 'engine.dbengine.on': True }) from myapp.application import Application root = Application(settings) application = cherrypy.Application(root, script_name='', config=settings) </code></pre> <p>I was using this <code>application.py</code> to mount my application into cherrypy's built in server when I was developing and testing it.</p> <p>The problems are that uWSGI does not create any threads itself and my SQLAlchemy plugin is not working with it, because no <code>cherrypy.engine</code> is created.</p> <p>Does uWSGI support threading in the meaning of using threads to serve multiple concurrent requests? Can I start these threads in my <code>application.py</code>? Will uWSGI understand it and use these threads for concurrent requests? And how can this be done? I think cherrypy can be used somehow, or not? And what about my SQLAlchemy Plugin, how can I start <code>cherrypy.engine</code> when using only WSGI <code>cherrypy.Application</code>?</p> <p>Any help or information that could help me will be appreciated.</p> <p><strong>Edit:</strong></p> <p>My uWSGI configuration:</p> <pre><code>&lt;uwsgi&gt; &lt;socket&gt;127.0.0.1:9001&lt;/socket&gt; &lt;master/&gt; &lt;daemonize&gt;/var/log/uwsgi/app.log&lt;/daemonize&gt; &lt;logdate/&gt; &lt;threads/&gt; &lt;pidfile&gt;/home/web/uwsgi.pid&lt;/pidfile&gt; &lt;uid&gt;uwsgi&lt;/uid&gt; &lt;gid&gt;uwsgi&lt;/gid&gt; &lt;workers&gt;2&lt;/workers&gt; &lt;harakiri&gt;90&lt;/harakiri&gt; &lt;harakiri-verbose/&gt; &lt;home&gt;/home/web/&lt;/home&gt; &lt;pythonpath&gt;/home/web/instance&lt;/pythonpath&gt; &lt;module&gt;core.application&lt;/module&gt; &lt;no-orphans/&gt; &lt;touch-reload&gt;/home/web/uwsgi-reload-web&lt;/touch-reload&gt; &lt;/uwsgi&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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