How to configure Py4web for multi user applications

269 views
Skip to first unread message

raghavender goud

unread,
Aug 20, 2021, 11:38:23 PM8/20/21
to py4web
Hi,

I'm a newbie to web application development, trying to build an app which will be used by multiple users concurrently. Right now I could see that Py4web processes the request in sequence. If there is an long running task other request are in queue and processed only after previous task completes.

One option i have is to create threads for long running tasks. I'm curious to know if py4web can be configured to process the request asynchronously? 

Massimo DiPierro

unread,
Aug 20, 2021, 11:53:35 PM8/20/21
to raghavender goud, py4web
py4web handles requests concurrently. Problem is that you may be using SQLite which is single threads and blocks the database on writing. So db access may make your request serial. You should use postgresql. Also you many to execute any long term running task in a background process. Maybe use celery.

--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/4f548b99-d6b0-42df-bb00-6f937ed5e33dn%40googlegroups.com.

raghavender goud

unread,
Aug 21, 2021, 12:11:03 AM8/21/21
to py4web
Hi Massimo,

We are using MySQL as the database, will Py4web process the requests concurrently with this database?

Massimo DiPierro

unread,
Aug 21, 2021, 1:45:07 AM8/21/21
to raghavender goud, py4web
It should. It uses the tornado web server by default. If your requests block for some reason you may have to use a multi threaded web server like rocket or cherrypy or waitress. You can select them with command line options, if installed. You can also take advantage of multiple CPUs with gunicorn. Let me know and can send more details istructions.

raghavender goud

unread,
Aug 21, 2021, 4:24:11 AM8/21/21
to py4web
Hi Massimo,

I do not use multiple workers option, start my application using the command "py4web run apps", let me know if using "-w" switch helps resolve my issue. 

Yes, by default is starts using "tornado". Let me know which server works best for my requirement, rocket or cherrypy or waitress. Any instructions on installation or usage will definitely help.


py4web run -h command lists following list of server options. 

  -s, --server [default|wsgiref|tornado|gunicorn|gevent|waitress|geventWebSocketServer|wsgirefThreadingServer|rocketServer]

This is my Py4web version: py4web: 1.20210328.2


Thank you.



Massimo DiPierro

unread,
Aug 21, 2021, 12:22:45 PM8/21/21
to raghavender goud, py4web
If concuccercy is more important than speed pip import rocket3 and use -w=rocketServer

raghavender goud

unread,
Sep 27, 2021, 11:49:50 PM9/27/21
to py4web

Have tried using rocket server,  this is throwing up database exceptions. Where ever we try to update an integer value in database we observer this error. Though the value is not null we see this error. Same code works fine with default tornodo server. Any ideas why we are seeing these errors?



  File "/home/raghu/Documents/testRunner/testRunner/framework/apps/mate/controllers.py", line 89, in update_config_to_db
    db.current_executions.insert(
  File "/home/raghu/mypyenv/lib/python3.8/site-packages/pydal/objects.py", line 890, in insert
    ret = self._db._adapter.insert(self, row.op_values())
  File "/home/raghu/mypyenv/lib/python3.8/site-packages/pydal/adapters/base.py", line 539, in insert
    query = self._insert(table, fields)
  File "/home/raghu/mypyenv/lib/python3.8/site-packages/pydal/adapters/base.py", line 534, in _insert
    ",".join(self.expand(v, f.type) for f, v in fields),
  File "/home/raghu/mypyenv/lib/python3.8/site-packages/pydal/adapters/base.py", line 534, in <genexpr>
    ",".join(self.expand(v, f.type) for f, v in fields),
  File "/home/raghu/mypyenv/lib/python3.8/site-packages/pydal/adapters/base.py", line 504, in _expand
    rv = self.represent(expression, field_type)
  File "/home/raghu/mypyenv/lib/python3.8/site-packages/pydal/adapters/base.py", line 437, in represent
    return super(SQLAdapter, self).represent(obj, field_type)
  File "/home/raghu/mypyenv/lib/python3.8/site-packages/pydal/adapters/base.py", line 391, in represent
    return self.representer.represent(obj, field_type)
  File "/home/raghu/mypyenv/lib/python3.8/site-packages/pydal/representers/__init__.py", line 246, in represent
    rv = self.get_representer_for_type(field_type)(rv, field_type)
  File "/home/raghu/mypyenv/lib/python3.8/site-packages/pydal/representers/__init__.py", line 138, in __call__
    return self.adapt(self.call(value, field_type))
  File "/home/raghu/mypyenv/lib/python3.8/site-packages/pydal/representers/__init__.py", line 135, in _call
    return self.inner_call(value)
  File "/home/raghu/mypyenv/lib/python3.8/site-packages/pydal/representers/__init__.py", line 123, in _inner_call
    return self.obj.f(self.representer, value, **kwargs)
  File "/home/raghu/mypyenv/lib/python3.8/site-packages/pydal/representers/base.py", line 29, in _integer
    return str(long(value))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'IS_EMPTY_OR'


Massimo

unread,
Oct 3, 2021, 11:15:15 PM10/3/21
to py4web
as mentioned in other tests. The problem is somewhere else. Not sure why it manifest itself only with rocket3
Reply all
Reply to author
Forward
0 new messages