py4web and celery

104 views
Skip to first unread message

Massimo Di Pierro

unread,
Dec 26, 2019, 5:38:31 AM12/26/19
to web2py-users
I posted an example of possible use of celery with py4web (in _scaffold) but I am not too happy about it.

db._adapter.reconnect() should be automatic and 'apps._scaffold.tasks' feels clunky.

Anyway, the example shows how you can define tasks and they can import anything they need from the app.
Works well for me but help me test it some more.

Massimo

JSalvat

unread,
Dec 26, 2019, 11:14:55 AM12/26/19
to web2py-users
Just installed from source but does not start:

unzipped source to c:\wwwroot\py4web

c:\wwwroot\py4web>python -m pip install -r requirements.txt --user
c:\wwwroot\py4web>python ./py4web-start.py apps
.....
Is still experimental...

Traceback (most recent call last):
  File "./py4web-start.py", line 6, in <module>
    main()
  File "c:\wwwroot\py4web\py4web\core.py", line 1047, in main
    initialize(**args.__dict__)
  File "c:\wwwroot\py4web\py4web\core.py", line 1008, in initialize
    apps = os.listdir(assets_dir)
FileNotFoundError: [WinError 3] El sistema no puede encontrar la ruta especificada: 'c:\\wwwroot\\py4web\\py4web\\assets'

c:\wwwroot\py4web>

Yesterday's release worked fine?

Massimo Di Pierro

unread,
Dec 26, 2019, 12:56:22 PM12/26/19
to web2py-users
fixed!

JSalvat

unread,
Dec 26, 2019, 1:17:23 PM12/26/19
to web2py-users
Massimo, now getting other errors:

Is still experimental...


Choose a one-time dashboard password:
Storing the hashed password in file "password.txt"
Dashboard is at: http://127.0.0.1:8000/_dashboard
[ ] loading examples ...
[A[X] loaded examples
[ ] loading sample ...
[A[X] loaded sample
[ ] loading todo ...
[A[X] loaded todo
[ ] loading _dashboard ...
[A[FAILED] loading _dashboard
Traceback (most recent call last):

 
File "C:\wwwroot\py4web\py4web\core.py", line 825, in import_app
    module_name
, init
 
File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
 
File "<frozen importlib._bootstrap_external>", line 907, in load_module
 
File "<frozen importlib._bootstrap_external>", line 732, in load_module
 
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
 
File "<frozen importlib._bootstrap>", line 696, in _load
 
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
 
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
 
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
 
File "apps\_dashboard\__init__.py", line 24, in <module>
    error_storage
= ErrorStorage()
 
File "C:\wwwroot\py4web\py4web\core.py", line 690, in __init__
   
self.db = DAL(uri, folder=folder)
 
File "C:\Users\salva\AppData\Roaming\Python\Python37\site-packages\pydal\base.py", line 171, in __call__
    obj
= super(MetaDAL, cls).__call__(*args, **kwargs)
 
File "C:\Users\salva\AppData\Roaming\Python\Python37\site-packages\pydal\base.py", line 477, in __init__
   
"Failure to connect, tried %d times:\n%s" % (attempts, tb)
RuntimeError: Failure to connect, tried 5 times:

Traceback (most recent call last):

 
File "C:\Users\salva\AppData\Roaming\Python\Python37\site-packages\pydal\base.py", line 457, in __init__
   
self._adapter = adapter(**kwargs)
 
File "C:\Users\salva\AppData\Roaming\Python\Python37\site-packages\pydal\adapters\__init__.py", line 39, in __call__
    obj
= super(AdapterMeta, cls).__call__(*args, **kwargs)
 
File "C:\Users\salva\AppData\Roaming\Python\Python37\site-packages\pydal\adapters\base.py", line 369, in __init__
   
super(SQLAdapter, self).__init__(*args, **kwargs)
 
File "C:\Users\salva\AppData\Roaming\Python\Python37\site-packages\pydal\adapters\base.py", line 53, in __init__
   
self.reconnect()
 
File "C:\Users\salva\AppData\Roaming\Python\Python37\site-packages\pydal\connection.py", line 154, in reconnect
   
self.connection = self.connector()
 
File "C:\Users\salva\AppData\Roaming\Python\Python37\site-packages\pydal\adapters\sqlite.py", line 42, in connector
   
return self.driver.Connection(self.dbpath, **self.driver_args)
sqlite3
.OperationalError: unable to open database file


[ ] loading _default ...
[A[X] loaded _default
[ ] loading _documentation ...
[A[X] loaded _documentation
[ ] loading _minimal ...
[A[X] loaded _minimal
[ ] loading _scaffold ...
[A[FAILED] loading _scaffold
Traceback (most recent call last):

 
File "C:\wwwroot\py4web\py4web\core.py", line 825, in import_app
    module_name
, init
 
File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
 
File "<frozen importlib._bootstrap_external>", line 907, in load_module
 
File "<frozen importlib._bootstrap_external>", line 732, in load_module
 
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
 
File "<frozen importlib._bootstrap>", line 696, in _load
 
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
 
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
 
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
 
File "apps\_scaffold\__init__.py", line 7, in <module>
   
from . models import db
 
File "apps\_scaffold\models.py", line 5, in <module>
   
from .common import db, Field
 
File "apps\_scaffold\common.py", line 102, in <module>
   
from celery import Celery
ModuleNotFoundError: No module named 'celery'

Bottle v0.12.18 server starting up (using WSGIRefServer())...
Listening on http://127.0.0.1:8000/
Hit Ctrl-C to quit.

JSalvat

unread,
Dec 26, 2019, 1:56:54 PM12/26/19
to web2py-users
May need to add  celery  to requirements  ?


Massimo Di Pierro

unread,
Dec 27, 2019, 4:37:24 AM12/27/19
to web2py-users
I changed to default to USE_CELERY=False

I do not want to make it dependent on celery.
Reply all
Reply to author
Forward
0 new messages