wooey / Wooey

A Django app that creates automatic web UIs for Python scripts.
http://wooey.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.12k stars 182 forks source link

Job In Waiting Status #317

Closed yapnel closed 4 years ago

yapnel commented 4 years ago

Hi,

I have just installed Wooey without any modification using pip install wooey, then, created a new project and execute python manage.py runserver to start up the server for testing. Then, uploaded a script via the admin panel and it was parsed successfully. Then, configured a job to execute the script. The job is stucked in Waiting status and doesn't seem to be doing anything at all. I didn't configure any broker or database.

Does Wooey work out of the box without any configuration changes? Kindly please advise

Thanks

yapnel commented 4 years ago

Now i have installed RabbitMQ and PostgresQL and both are up and running fine. Below is my user.setting configuration. Executed python manage.py migrate and createcache table and i can see all the tables in postgresql. Started the runserver without any issue. However, when i execute celery -A ProjectName worker --pool=eventlet -l info, i'm seeing errors below even though it has managed to connect to RabbitMQ successfully. What have I done incorrectly on the setup? When i submit a job it just in waiting status and nothing happens.

[2020-04-21 12:02:37,557: INFO/MainProcess] celery@HOSTNAME ready. [2020-04-21 12:02:37,557: INFO/MainProcess] Received task: wooey.tasks.submit_script[17088d07-e631-4dd7-988c-56afceafc96f] [2020-04-21 12:02:37,572: INFO/MainProcess] Received task: wooey.tasks.submit_script[d2262fab-7394-4689-9cdb-5888aa68a89d] [2020-04-21 12:02:37,588: INFO/MainProcess] pidbox: Connected to amqp://guest:@127.0.0.1:5672//. [2020-04-21 12:02:37,666: ERROR/MainProcess] Signal handler <function task_completed at 0x00000000059B4378> raised: DatabaseError("DatabaseWrapper obj ects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 47817448 and this is thread id 96500424.") Traceback (most recent call last): File "c:\temp\bitbucket\wooey\env\lib\site-packages\wooey\signals.py", line 24, in task_completed job = WooeyJob.objects.get(pk=job_id) File "c:\temp\bitbucket\wooey\env\lib\site-packages\django\db\models\manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(*args, *kwargs) File "c:\temp\bitbucket\wooey\env\lib\site-packages\django\db\models\query.py", line 411, in get num = len(clone) File "c:\temp\bitbucket\wooey\env\lib\site-packages\django\db\models\query.py", line 258, in len self._fetch_all() File "c:\temp\bitbucket\wooey\env\lib\site-packages\django\db\models\query.py", line 1261, in _fetch_all self._result_cache = list(self._iterable_class(self)) File "c:\temp\bitbucket\wooey\env\lib\site-packages\django\db\models\query.py", line 57, in iter results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size) File "c:\temp\bitbucket\wooey\env\lib\site-packages\django\db\models\sql\compiler.py", line 1149, in execute_sql cursor = self.connection.cursor() File "c:\temp\bitbucket\wooey\env\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(args, kwargs) File "c:\temp\bitbucket\wooey\env\lib\site-packages\django\db\backends\base\base.py", line 260, in cursor return self._cursor() File "c:\temp\bitbucket\wooey\env\lib\site-packages\django\db\backends\base\base.py", line 238, in _cursor return self._prepare_cursor(self.create_cursor(name)) File "c:\temp\bitbucket\wooey\env\lib\site-packages\django\db\backends\base\base.py", line 228, in _prepare_cursor self.validate_thread_sharing() File "c:\temp\bitbucket\wooey\env\lib\site-packages\django\db\backends\base\base.py", line 558, in validate_thread_sharing % (self.alias, self._thread_ident, _thread.get_ident()) django.db.utils.DatabaseError: DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was c reated in thread id 47817448 and this is thread id 96500424.

import errno import os from .wooey_settings import * INSTALLED_APPS += ( )

WOOEY_ALLOW_ANONYMOUS = True

INSTALLED_APPS += ( 'django_celery_results', 'kombu.transport.filesystem', )

CELERY_RESULT_BACKEND = 'django-db' CELERY_BROKER_URL = 'amqp://guest:guest@localhost:5672/' CELERY_BROKER_POOL_LIMIT = 1 CELERYD_CONCURRENCY = 1 CELERY_TASK_SERIALIZER = 'json' CELERY_TASK_ACKS_LATE = True

def ensure_path(path): try: os.makedirs(path) except Exception as e: if e.errno == errno.EEXIST: pass else: raise return path

broker_dir = ensure_path(os.path.join(BASE_DIR, '.broker')) CELERY_BROKER_TRANSPORT_OPTIONS = { "data_folder_in": ensure_path(os.path.join(broker_dir, "out")), "data_folder_out": ensure_path(os.path.join(broker_dir, "out")), "data_folder_processed": ensure_path(os.path.join(broker_dir, "processed")), }

CELERY_TRACK_STARTED = True WOOEY_CELERY = True CELERY_SEND_EVENTS = True CELERY_IMPORTS = ('wooey.tasks',)

WOOEY_REALTIME_CACHE = 'default' CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.db.DatabaseCache', 'LOCATION': 'wooey_cache_table', } }

MEDIA_ROOT = os.path.join(BASE_DIR, 'user_uploads') MEDIA_URL = '/uploads/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/'

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'wooey_db', 'USER': 'XXXX', 'PASSWORD': 'XXXX', 'HOST': 'XXXX', 'PORT': '5432' } } AUTHENTICATION_BACKEND = 'django.contrib.auth.backends.ModelBackend'

yapnel commented 4 years ago

Looks like a celery issue supporting Windows. Tried different pool type and the only one that worked for me is gevent. The rest throws errors!

Chris7 commented 4 years ago

Thanks for the update! I'll add that note to the docs. Did you happen to come across https://wooey.readthedocs.io/en/latest/running_wooey.html while implementing it?

yapnel commented 4 years ago

I have studied your documents 😃